OLLM

Vercel AI SDK Integration

How to integrate OLLM with the Vercel AI SDK for secure, confidential LLM access.

The OLLM provider enables you to use OLLM models directly with the AI SDK through a unified, OpenAI-compatible interface.

All models accessed through this provider execute with confidential computing enabled by default. From the SDK’s perspective, you interact with OLLM like any other model provider, but inference runs inside hardware-backed Trusted Execution Environments (TEEs) with zero data retention.

Using the provider gives you:

  • Confidential model execution — All models run inside TEEs
  • Zero data retention — Prompts and completions are not stored
  • Unified API access — One API key across supported models
  • OpenAI-compatible integration — Works seamlessly with generateText, streamText, and other AI SDK utilities
  • Verifiable execution guarantees — Backed by confidential computing infrastructure

This page covers installation, initialization, and usage examples for integrating OLLM models into your AI SDK applications.

Setup

The OLLM provider is available in the @ofoundation/ollm module.

Install using your preferred package manager:

pnpm add @ofoundation/ollm
npm install @ofoundation/ollm
yarn add @ofoundation/ollm
bun add @ofoundation/ollm

Create a Provider Instance

Import and initialize the provider using createOLLM.

provider-setup.ts
import { createOLLM } from '@ofoundation/ollm';
const ollm = createOLLM({
  apiKey: 'YOUR_OLLM_API_KEY',
});

You can obtain your API key from the OLLM Dashboard.

Language Models

All OLLM models run with confidential computing enabled by default.

Use ollm.chatModel() to access chat-capable models:

specify-model.ts
const confidentialModel = ollm.chatModel('near/GLM-4.7');

The model identifier must match one of the available models exposed by OLLM.

Refer to the OLLM Models page for the full catalog.

Examples

generateText

generate-text.ts
import { createOLLM } from '@ofoundation/ollm';
import { generateText } from 'ai';
const ollm = createOLLM({
  apiKey: 'YOUR_OLLM_API_KEY',
});
const { text } = await generateText({
  model: ollm.chatModel('near/GLM-4.6'),
  prompt: 'What is OLLM?',
});
console.log(text);

streamText

stream-text.ts
import { createOLLM } from '@ofoundation/ollm';
import { streamText } from 'ai';
const ollm = createOLLM({
  apiKey: 'YOUR_OLLM_API_KEY',
});
const result = streamText({
  model: ollm.chatModel('near/GLM-4.6'),
  prompt: 'Write a short story about secure AI.',
});
for await (const chunk of result.textStream) {
  console.log(chunk);
}

Using System Messages

system-messages.ts
import { createOLLM } from '@ofoundation/ollm';
import { generateText } from 'ai';
const ollm = createOLLM({
  apiKey: 'YOUR_OLLM_API_KEY',
});
const { text } = await generateText({
  model: ollm.chatModel('near/GLM-4.6'),
  system: 'You are a helpful assistant that responds concisely.',
  prompt: 'What is TypeScript in one sentence?',
});
console.log(text);

Security & Confidential Computing

All models accessed through OLLM execute inside Trusted Execution Environments (TEEs). This provides:

Zero Data Retention (ZDR)

Prompts and completions are not stored or logged by providers.

Confidential Computing

Hardware-level encryption ensures data remains protected during processing.

Verifiable Privacy

Inference runs inside attested environments, enabling cryptographic verification of execution integrity.

Model Flexibility

OLLM provides access to multiple models from many providers under a single API key. All OLLM models run with confidential computing by default. Use ollm.chatModel() for chat models:

model-selection.ts
// Confidential computing chat models
const confidentialModel = ollm.chatModel('near/GLM-4.7');

No additional API keys or provider-specific SDK integrations are required.

Cost & Usage Tracking

Usage and token accounting are available through the OLLM dashboard, enabling:

  • Real-time cost monitoring
  • Per-model usage visibility
  • Operational tracking

Enterprise Features

For high-volume or regulated workloads, OLLM offers:

  • Enterprise support
  • Custom SLAs
  • Dedicated assistance

Tool Integrations

OLLM works with popular AI development environments and tools, including:

  • Cursor
  • Visual Studio Code
  • Replit
  • Windsurf
  • Cline
  • Roo Code

These tools can connect using OLLM’s OpenAI-compatible interface.

On this page