{"_id":"@ai-toolkit/openai-compatible","name":"@ai-toolkit/openai-compatible","dist-tags":{"latest":"0.1.13"},"versions":{"0.1.13":{"name":"@ai-toolkit/openai-compatible","version":"0.1.13","license":"Apache-2.0","sideEffects":false,"main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{"./package.json":"./package.json",".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./internal":{"types":"./internal/dist/index.d.ts","import":"./internal/dist/index.mjs","module":"./internal/dist/index.mjs","require":"./internal/dist/index.js"}},"dependencies":{"@ai-toolkit/provider":"1.0.10","@ai-toolkit/provider-utils":"2.1.11"},"devDependencies":{"@types/node":"^18","tsup":"^8","typescript":"5.6.3","zod":"3.23.8","@khulnasoft/ai-tsconfig":"0.0.0"},"peerDependencies":{"zod":"^3.0.0"},"engines":{"node":">=18"},"publishConfig":{"access":"public"},"homepage":"https://sdk.khulnasoft.com/docs","repository":{"type":"git","url":"git+https://github.com/khulnasoft/ai-toolkit.git"},"bugs":{"url":"https://github.com/khulnasoft/ai-toolkit/issues"},"keywords":["ai-toolkit"],"scripts":{"build":"tsup","build:watch":"tsup --watch","clean":"rm -rf dist && rm -rf internal/dist","lint":"eslint \"./**/*.ts*\"","type-check":"tsc --noEmit","prettier-check":"prettier --check \"./**/*.ts*\"","test":"pnpm test:node && pnpm test:edge","test:edge":"vitest --config vitest.edge.config.js --run","test:node":"vitest --config vitest.node.config.js --run"},"_id":"@ai-toolkit/openai-compatible@0.1.13","description":"This package provides a foundation for implementing providers that expose an OpenAI-compatible API.","_integrity":"sha512-mIyt/7XuuzkFdfWtvAOpGgHk1XpSJErq1OxROM3VDPniNZhlABaKfGpezAITHIobxE5hF1NW/1nZi0yRaFLtuQ==","_resolved":"/tmp/3ee7a2a4af017323fe9fc9a9dcdd7a38/ai-toolkit-openai-compatible-0.1.13.tgz","_from":"file:ai-toolkit-openai-compatible-0.1.13.tgz","_nodeVersion":"22.13.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-mIyt/7XuuzkFdfWtvAOpGgHk1XpSJErq1OxROM3VDPniNZhlABaKfGpezAITHIobxE5hF1NW/1nZi0yRaFLtuQ==","shasum":"5fcb7418f246265cc80038fcd377785c9a0d0ddc","tarball":"https://registry.npmjs.org/@ai-toolkit/openai-compatible/-/openai-compatible-0.1.13.tgz","fileCount":15,"unpackedSize":302090,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC4oYpLJLEZGHJkAwn3ZobDQreUUWdzdTuauxOtSIg7kAIga34FmRFecqKM0BRDFChOpHoUdTklrKWiqkzdDryo4As="}]},"_npmUser":{"name":"khulnasoft-lab","email":"iconmamundentist@gmail.com"},"directories":{},"maintainers":[{"name":"khulnasoft-lab","email":"iconmamundentist@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/openai-compatible_0.1.13_1741546717508_0.7209352414164238"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-09T18:58:37.381Z","0.1.13":"2025-03-09T18:58:37.682Z","modified":"2025-03-09T18:58:37.991Z"},"maintainers":[{"name":"khulnasoft-lab","email":"iconmamundentist@gmail.com"}],"description":"This package provides a foundation for implementing providers that expose an OpenAI-compatible API.","homepage":"https://sdk.khulnasoft.com/docs","keywords":["ai-toolkit"],"repository":{"type":"git","url":"git+https://github.com/khulnasoft/ai-toolkit.git"},"bugs":{"url":"https://github.com/khulnasoft/ai-toolkit/issues"},"license":"Apache-2.0","readme":"# AI TOOLKIT - OpenAI Compatible Provider\n\nThis package provides a foundation for implementing providers that expose an OpenAI-compatible API.\n\nThe primary [OpenAI provider](../openai/README.md) is more feature-rich, including OpenAI-specific experimental and legacy features. This package offers a lighter-weight alternative focused on core OpenAI-compatible functionality.\n\n## Setup\n\nThe provider is available in the `@ai-toolkit/openai-compatible` module. You can install it with\n\n```bash\nnpm i @ai-toolkit/openai-compatible\n```\n\n## Provider Instance\n\nYou can import the provider creation method `createOpenAICompatible` from `@ai-toolkit/openai-compatible`:\n\n```ts\nimport { createOpenAICompatible } from '@ai-toolkit/openai-compatible';\n```\n\n## Example\n\n```ts\nimport { createOpenAICompatible } from '@ai-toolkit/openai-compatible';\nimport { generateText } from 'ai-toolkit';\n\nconst { text } = await generateText({\n  model: createOpenAICompatible({\n    baseURL: 'https://api.example.com/v1',\n    name: 'example',\n    apiKey: process.env.MY_API_KEY,\n  }).chatModel('meta-llama/Llama-3-70b-chat-hf'),\n  prompt: 'Write a vegetarian lasagna recipe for 4 people.',\n});\n```\n\n### Customizing headers\n\nYou can further customize headers if desired. For example, here is an alternate implementation to pass along api key authentication:\n\n```ts\nimport { createOpenAICompatible } from '@ai-toolkit/openai-compatible';\nimport { generateText } from 'ai-toolkit';\n\nconst { text } = await generateText({\n  model: createOpenAICompatible({\n    baseURL: 'https://api.example.com/v1',\n    name: 'example',\n    headers: {\n      Authorization: `Bearer ${process.env.MY_API_KEY}`,\n    },\n  }).chatModel('meta-llama/Llama-3-70b-chat-hf'),\n  prompt: 'Write a vegetarian lasagna recipe for 4 people.',\n});\n```\n\n### Including model ids for auto-completion\n\n```ts\nimport { createOpenAICompatible } from '@ai-toolkit/openai-compatible';\nimport { generateText } from 'ai-toolkit';\n\ntype ExampleChatModelIds =\n  | 'meta-llama/Llama-3-70b-chat-hf'\n  | 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo'\n  | (string & {});\n\ntype ExampleCompletionModelIds =\n  | 'codellama/CodeLlama-34b-Instruct-hf'\n  | 'Qwen/Qwen2.5-Coder-32B-Instruct'\n  | (string & {});\n\ntype ExampleEmbeddingModelIds =\n  | 'BAAI/bge-large-en-v1.5'\n  | 'bert-base-uncased'\n  | (string & {});\n\nconst model = createOpenAICompatible<\n  ExampleChatModelIds,\n  ExampleCompletionModelIds,\n  ExampleEmbeddingModelIds\n>({\n  baseURL: 'https://api.example.com/v1',\n  name: 'example',\n  apiKey: process.env.MY_API_KEY,\n});\n\n// Subsequent calls to e.g. `model.chatModel` will auto-complete the model id\n// from the list of `ExampleChatModelIds` while still allowing free-form\n// strings as well.\n\nconst { text } = await generateText({\n  model: model.chatModel('meta-llama/Llama-3-70b-chat-hf'),\n  prompt: 'Write a vegetarian lasagna recipe for 4 people.',\n});\n```\n\nFor more examples, see the [OpenAI Compatible Providers](https://sdk.khulnasoft.com/providers/openai-compatible-providers) documentation.\n","readmeFilename":"README.md","_rev":"1-e61b7568ce47a21421085fa6126239d4"}