Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 15x 15x 2x 2x 2x 2x 2x 9x 9x 9x 9x | import { ModelInfo } from "../Provider.js";
import { Capabilities } from "./Capabilities.js";
import { ModelRegistry } from "../../models/ModelRegistry.js";
export class AnthropicModels {
constructor(
private readonly baseUrl: string,
private readonly apiKey: string
) {}
async execute(): Promise<ModelInfo[]> {
try {
const response = await fetch(`${this.baseUrl}/models`, {
method: "GET",
headers: {
"x-api-key": this.apiKey,
"anthropic-version": "2023-06-01",
"content-type": "application/json"
}
});
Eif (response.ok) {
const { data } = (await response.json()) as {
data: { id: string; display_name: string; created_at: string }[];
};
return data.map((m) => {
const modelId = m.id;
const registryModel = ModelRegistry.find(modelId, "anthropic");
const info: ModelInfo = {
id: modelId,
name: registryModel?.name || m.display_name || modelId,
provider: "anthropic",
family: registryModel?.family || modelId,
context_window: registryModel?.context_window || Capabilities.getContextWindow(modelId),
max_output_tokens:
registryModel?.max_output_tokens || Capabilities.getMaxOutputTokens(modelId),
modalities: registryModel?.modalities || { input: ["text"], output: ["text"] },
capabilities: Capabilities.getCapabilities(modelId),
pricing: registryModel?.pricing || Capabilities.getPricing(modelId),
metadata: {
...(registryModel?.metadata || {}),
display_name: m.display_name,
created_at: m.created_at
}
};
return info;
});
}
} catch (_error) {
// Fallback
}
return ModelRegistry.all()
.filter((m) => m.provider === "anthropic")
.map((m) => ({
...m,
capabilities: Capabilities.getCapabilities(m.id)
})) as ModelInfo[];
}
find(modelId: string) {
return ModelRegistry.find(modelId, "anthropic");
}
}
|