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/gatewaynpm install @orgn/gatewayyarn add @orgn/gatewaybun add @orgn/gatewayCreate 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):
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:
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)
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)
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
| Capability | Status |
|---|---|
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
| Tier | IDs | Proof |
|---|---|---|
| TEE | near_*, phala_* | Attestation receipt — verify in Scanner |
| ZDR | vercel_* | 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().
Related
- Gateway models — catalog by modality
- OpenAI SDK guide — drop-in migration
- Gateway console API keys
Gateway Integrations
Integrate ORGN Gateway into your applications with OpenAI-compatible SDKs, the Vercel AI SDK, and direct HTTP. One API key, hundreds of models, TEE and ZDR execution.
Gateway API Requests and Response Structure
How ORGN Gateway structures API requests and responses — success envelopes, error handling, usage metadata, and TEE attestation receipts.