UNPKG

@anthropic-ai/sdk

Version:
66 lines • 2.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Models = void 0; const resource_1 = require("../core/resource.js"); const pagination_1 = require("../core/pagination.js"); const headers_1 = require("../internal/headers.js"); const tracing_1 = require("../internal/tracing.js"); const path_1 = require("../internal/utils/path.js"); class Models extends resource_1.APIResource { /** * Get a specific model. * * The Models API response can be used to determine information about a specific * model or resolve a model alias to a model ID. * * @example * ```ts * const modelInfo = await client.models.retrieve('model_id'); * ``` */ retrieve(modelID, params = {}, options) { const { workspace_id } = params ?? {}; return this._client.get((0, path_1.path) `/v1/models/${modelID}`, { ...options, headers: (0, headers_1.buildHeaders)([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: (0, tracing_1.startApiCallSpan)(this._client, 'anthropic.models.retrieve', options, { route: '/v1/models/{model_id}', attributes: { 'anthropic.model.id': modelID }, }), }); } /** * List available models. * * The Models API response can be used to determine which models are available for * use in the API. More recently released models are listed first. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const modelInfo of client.models.list()) { * // ... * } * ``` */ list(params = {}, options) { const { workspace_id, ...query } = params ?? {}; return this._client.getAPIList('/v1/models', (pagination_1.Page), { query, ...options, headers: (0, headers_1.buildHeaders)([ { ...(workspace_id != null ? { 'anthropic-workspace-id': workspace_id } : undefined) }, options?.headers, ]), __span: (0, tracing_1.startApiCallSpan)(this._client, 'anthropic.models.list', options, { route: '/v1/models', queryParams: ['after_id', 'before_id', 'lifecycle', 'limit'], }), }); } } exports.Models = Models; //# sourceMappingURL=models.js.map