xsAI v0.3 "future base" is now available! Read Announcement
xsAI0.4.0-beta.10

Providers

Collection of predefined providers.

This package is not recommended for xsAI-based libraries, which can increase the size of the installation.

npm i @xsai-ext/providers

Usage

Predefined

It reads the API Key from the environment variables via process.env, so it cannot be used in a browser.

import {  } from '@xsai-ext/providers'
import {  } from '@xsai/generate-text'
import {  } from 'node:process'

const {  } = await ({
  ....('gemini-2.5-flash'), 
  : .!, 
  : 'https://generativelanguage.googleapis.com/v1beta/openai/', 
  : [{
    : 'Why is the sky blue?',
    : 'user'
  }],
  : 'gemini-2.5-flash', 
})

Create

You can also import a create function instead of a predefined provider, making it runtime-agnostic:

// import { google } from '@xsai-ext/providers'
import {  } from '@xsai-ext/providers/create'
import {  } from '@xsai/generate-text'

const  = ('YOUR_API_KEY_HERE') 

const {  } = await ({
  ....('gemini-2.5-flash'),
  : [{
    : 'Why is the sky blue?',
    : 'user'
  }],
})

Deprecated

Please migrate to the Providers package as soon as possible. The legacy packages will be officially deprecated in v0.4.0.

Cloud

install sizeminified sizeminzipped size
npm i @xsai-ext/providers-cloud

Examples

Keys

Checkout all supported providers here.

import * as  from '@xsai-ext/providers-cloud'

type  = keyof typeof 
OpenAI
import {  } from '@xsai-ext/providers-cloud'
import {  } from '@xsai/generate-text'
import {  } from 'node:process'

const  = (.!) 

const {  } = await ({
  ....('gpt-4o'), 
  : .!, 
  : 'https://api.openai.com/v1/', 
  : [{
    : 'Why is the sky blue?',
    : 'user'
  }],
  : 'gpt-4o', 
})

Local

install sizeminified sizeminzipped size
npm i @xsai-ext/providers-local

Examples

Keys

Checkout all supported providers here.

import * as  from '@xsai-ext/providers-local'

type  = keyof typeof 
Ollama
import {  } from '@xsai-ext/providers-local'
import {  } from '@xsai/generate-text'
import {  } from 'node:process'

const  = () 

const {  } = await ({
  ....('llama3.2'), 
  : 'http://localhost:11434/v1/', 
  : [{
    : 'Why is the sky blue?',
    : 'user'
  }],
  : 'llama3.2', 
})