Providers

OpenAI, Anthropic, Gemini, and Ollama.

1 min readEdit this page

OpenAI

import { OpenAIProvider } from '@restjs/ai'
const ai = new OpenAIProvider({ apiKey: process.env.OPENAI_API_KEY })

Anthropic

import { AnthropicProvider } from '@restjs/ai'
const ai = new AnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY })

Gemini

import { GeminiProvider } from '@restjs/ai'
const ai = new GeminiProvider({ apiKey: process.env.GOOGLE_API_KEY })

Ollama (local)

import { OllamaProvider } from '@restjs/ai'
const ai = new OllamaProvider({ model: 'llama3.2' })

All share: ai.complete(), ai.stream(), ai.embed()

Note

Provider HTTP errors are caught — the server never crashes from a failed AI call.