UNPKG

@anthropic-ai/sdk

Version:

The official TypeScript library for the Anthropic API

56 lines 1.93 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import { Page } from "../../core/pagination.mjs"; import { buildHeaders } from "../../internal/headers.mjs"; import { path } from "../../internal/utils/path.mjs"; export class Models extends 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 betaModelInfo = await client.beta.models.retrieve( * 'model_id', * ); * ``` */ retrieve(modelID, params = {}, options) { const { betas } = params ?? {}; return this._client.get(path `/v1/models/${modelID}?beta=true`, { ...options, headers: buildHeaders([ { ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) }, options?.headers, ]), }); } /** * 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 betaModelInfo of client.beta.models.list()) { * // ... * } * ``` */ list(params = {}, options) { const { betas, ...query } = params ?? {}; return this._client.getAPIList('/v1/models?beta=true', (Page), { query, ...options, headers: buildHeaders([ { ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) }, options?.headers, ]), }); } } //# sourceMappingURL=models.mjs.map