Models
List and describe the various models available in the API.
npm i @xsai/model
Examples
listModels
import { listModels } from '@xsai/model'
import { env } from 'node:process'
// [
// {
// "id": "model-id-0",
// "object": "model",
// "created": 1686935002,
// "owned_by": "organization-owner"
// },
// {
// "id": "model-id-1",
// "object": "model",
// "created": 1686935002,
// "owned_by": "organization-owner",
// },
// {
// "id": "model-id-2",
// "object": "model",
// "created": 1686935002,
// "owned_by": "openai"
// },
// ]
const models = await listModels({
apiKey: env.OPENAI_API_KEY!,
baseURL: 'https://api.openai.com/v1/',
})
retrieveModel
import { retrieveModel } from '@xsai/model'
import { env } from 'node:process'
// {
// "id": "gpt-4o",
// "object": "model",
// "created": 1686935002,
// "owned_by": "openai"
// }
const model = await retrieveModel({
apiKey: env.OPENAI_API_KEY!,
baseURL: 'https://api.openai.com/v1/',
model: 'gpt-4o',
})