OpenAI Compatible
Usage
OPENAI_COMPATIBLE_API_KEY=import { TokenJS } from 'token.js'
// Create the Token.js client and specify the baseURL for the OpenAI v1 API compatible provider
const tokenjs = new TokenJS({
baseURL: 'http://127.0.0.1:11434/v1/',
})
async function main() {
// Create a model response
const completion = await tokenjs.chat.completions.create({
// Specify the provider and model
provider: 'openai-compatible',
model: 'llama3.2',
// Define your messages
messages: [
{
role: 'user',
content: 'Hello!',
},
],
})
console.log(completion.choices[0])
}
main()Compatibility
OpenAI Compatible Providers
Official Support for Specific Providers
Last updated