Origin Docs
Integrations

ORGN Gateway with the Vercel AI SDK

Integrate ORGN Gateway with the Vercel AI SDK via @orgn/gateway — TEE models with attestation receipts or ZDR frontier models through one provider.

The @orgn/gateway module exposes an OpenAI-compatible provider for the Vercel AI SDK. Route inference through ORGN Gateway with the same generateText, streamText, embed, and experimental_transcribe helpers you already use.

TEE vs ZDR: Model ID prefix determines execution — near_* / phala_* = TEE + Scanner receipts; vercel_* = ZDR policy retention, no hardware receipt. The SDK does not auto-select tier; you pick the model.

Setup

Install @orgn/gateway:

pnpm add @orgn/gateway
npm install @orgn/gateway
yarn add @orgn/gateway
bun add @orgn/gateway

Create an API key in the Gateway console and export it:

export OLLM_API_KEY="sk-ollm-..."

The env var name OLLM_API_KEY is a legacy convention from the OLLM v2 SDK — the product is ORGN Gateway; keys still use the sk-ollm- prefix.

Create a provider instance

The package exports createOLLM (legacy export name):

provider-setup.ts
import { createOLLM } from '@orgn/gateway';

const gateway = createOLLM({
  apiKey: process.env.OLLM_API_KEY,
  // baseURL: 'https://api.gateway.orgn.com/v1',  // default
});

Or use the default export:

import { ollm } from '@orgn/gateway';

Discovering available models

Fetch the live catalog instead of hardcoding IDs:

list-models.ts
const all = await ollm.listModels();
const chat = await ollm.listModels({ inputModality: 'text', outputModality: 'text' });
const embeddings = await ollm.listModels({ outputModality: 'embedding' });

Example entry:

{
  id: 'near_glm_4_7',
  display_name: 'GLM 4.7',
  model_info: { TEE: true },
}

Use id directly with chatModel(), embeddingModel(), or transcriptionModel().

Examples

generateText (TEE)

generate-text.ts
import { createOLLM } from '@orgn/gateway';
import { generateText } from 'ai';

const gateway = createOLLM({ apiKey: process.env.OLLM_API_KEY });

const { text } = await generateText({
  model: gateway.chatModel('near_glm_4_7'),
  prompt: 'What is ORGN Gateway?',
});

streamText (ZDR)

stream-text.ts
const result = streamText({
  model: gateway.chatModel('vercel_claude_sonnet_4_6'),
  prompt: 'Write a short paragraph about secure AI.',
});

System messages and multi-turn

await generateText({
  model: gateway.chatModel('near_glm_4_7'),
  system: 'You are a concise technical assistant.',
  prompt: 'Explain TLS in two sentences.',
});

Provider options

await generateText({
  model: gateway.chatModel('vercel_gpt_5'),
  prompt: 'Walk me through the proof.',
  providerOptions: {
    ollm: {
      reasoningEffort: 'high',
      user: 'user-1234',
    },
  },
});

providerOptions.ollm is the shipped SDK namespace (legacy name).

Multimodal input

Pass images or PDFs as file content parts — use a model whose input_modalities include the type you need (check listModels()).

const { text } = await generateText({
  model: gateway.chatModel('vercel_claude_sonnet_4_6'),
  messages: [{
    role: 'user',
    content: [
      { type: 'text', text: 'Describe this image.' },
      { type: 'file', data: image, mediaType: 'image/jpeg' },
    ],
  }],
});

Embeddings

const { embedding } = await embed({
  model: gateway.embeddingModel('near_qwen3_embedding_0_6b'),
  value: 'ORGN Gateway routes confidential LLM traffic.',
});

Audio transcription

import { experimental_transcribe as transcribe } from 'ai';

const result = await transcribe({
  model: gateway.transcriptionModel('near_whisper_large_v3'),
  audio,
});

What is not supported

CapabilityStatus
imageModel() (text → image)Throws NoSuchModelError — use raw HTTP for image-output models
completionModel() (legacy /v1/completions)Use chatModel() only
Speech generation (TTS)No TTS models in catalog

Security by model tier

TierIDsProof
TEEnear_*, phala_*Attestation receipt — verify in Scanner
ZDRvercel_*Policy zero retention — no hardware receipt

See Models overview and Verification.

API reference (exports)

import {
  createOLLM,
  ollm,
  type OLLMProvider,
  type OLLMModel,
  type ListModelsOptions,
} from '@orgn/gateway';

OLLMProvider methods: chatModel(), embeddingModel(), transcriptionModel(), listModels().

On this page