@shpitdev/foundry-ai
v0.1.0
Published
Thin Palantir Foundry provider adapters and model catalog for the Vercel AI SDK.
Maintainers
Readme
@shpitdev/foundry-ai
Use Vercel AI SDK language models, GPT-6 Luna decisions, OpenAI embeddings, and realtime audio through Palantir Foundry's proxy endpoints.
Formerly @nyrra/foundry-ai: versions up to 0.0.9 stay there, deprecated. To move, replace the package name in your dependencies and imports; the API is unchanged.
Install
Install only the provider peers you use:
pnpm add @shpitdev/foundry-ai ai@7 @ai-sdk/openai@4Use @ai-sdk/anthropic for Claude, @ai-sdk/google for Gemini, @ai-sdk/xai for Grok, and @ai-sdk/openai for Gemma. Use stable AI SDK 7 with provider v4 (OpenAI Compatible v3) for new integrations. AI SDK 6/provider v3 (OpenAI Compatible v2) and the late SDK 7 beta line from 7.0.0-beta.187 remain compatible, but the current live survey uses stable SDK 7.
Configure and call a model
Set FOUNDRY_URL and FOUNDRY_TOKEN in your server environment. Optional variables are FOUNDRY_ATTRIBUTION_RID, FOUNDRY_TRACE_PARENT, and FOUNDRY_TRACE_STATE. Keep server tokens out of browser code.
import { loadFoundryConfig } from '@shpitdev/foundry-ai';
import { createFoundryOpenAI } from '@shpitdev/foundry-ai/openai';
import { generateText } from 'ai';
const openai = createFoundryOpenAI(loadFoundryConfig());
const { text } = await generateText({
model: openai('gpt-5-mini'),
prompt: 'Reply in one sentence.',
});
console.log(text);For explicit configuration, pass { foundryUrl, token } to the factory. Other factories are createFoundryAnthropic, createFoundryGoogle, and createFoundryXai, imported from the anthropic, google, and xai subpaths.
Models and test status covers model IDs, routing, known failures, and dated live results. Catalog membership alone does not establish feature support. CI verifies SDK compatibility offline; live Foundry probes are manual.
xAI / Grok
Install @ai-sdk/xai@4 with AI SDK 7 (or @ai-sdk/xai@3 with SDK 6). The xAI subpath does not require the OpenAI peer.
import { createFoundryXai } from '@shpitdev/foundry-ai/xai';
const xai = createFoundryXai(loadFoundryConfig());
const model = xai('grok-4-6'); // Uses the xAI Responses route.Grok uses model identity foundry-xai, catalog provider xai, registry prefix xai:, and providerOptions.xai. See xAI setup and the current Grok results for verified capabilities and remaining gaps.
Open-weight models
Install @ai-sdk/openai-compatible@3 with AI SDK 7 for DeepSeek, NVIDIA Nemotron, Qwen, Moonshot Kimi, and Z.ai GLM (use @ai-sdk/openai-compatible@2 with AI SDK 6). For Gemma, install @ai-sdk/openai instead.
import { createFoundryDeepSeek } from '@shpitdev/foundry-ai/deepseek';
const deepseek = createFoundryDeepSeek(loadFoundryConfig());
const model = deepseek('deepseek-v3.2');The other factories are createFoundryNvidia, createFoundryQwen, createFoundryMoonshot, createFoundryZai, and createFoundryGemma, on the nvidia, qwen, moonshot, zai, and gemma subpaths. See model routing and live results for aliases and feature limits.
Embeddings and multiple providers
import { embed } from 'ai';
const { embedding } = await embed({
model: openai.embeddingModel('text-embedding-3-small'),
value: 'Text to embed',
});Compose multiple providers with AI SDK createProviderRegistry; this package exports no registry wrapper. See the runnable examples for registry and tool workflows.
Server environment configuration is the validated runtime path. Palantir TSv1/TSv2 functions and PlatformClient fetch integration have not been verified end to end.
Decisions (GPT-6 Luna)
openai.decisionModel('gpt-6-luna') routes AI SDK's experimental_decide through Foundry's OpenAI /decisions proxy. Verified with ai 7.0.176 and @ai-sdk/openai 4.0.121; earlier SDK 7 releases had incompatible experimental decision contracts, and an @ai-sdk/openai without decisionModel throws.
import { experimental_decide as decide } from 'ai';
const { answers } = await decide({
model: openai.decisionModel('gpt-6-luna'),
state: 'My order arrived with a cracked screen.',
questions: {
damaged: { type: 'boolean', instructions: 'Is a damaged item reported?' },
route: {
type: 'choice',
instructions: 'Which team?',
criteria: { billing: null, shipping: null },
},
},
});Boolean, choice, and score questions are supported. Do not set providerOptions.openai.promptCacheKey; Foundry rejects it with HTTP 400. See decision results.
Realtime (AI SDK 7 only)
Use createFoundryRealtime and createFoundryRealtimeSetup from @shpitdev/foundry-ai/realtime with gpt-realtime, gpt-realtime-1.5, gpt-realtime-2, gpt-realtime-2.1, or gpt-realtime-2.1-mini. Install ai@7 and @ai-sdk/openai@4; this subpath uses the SDK's experimental realtime interface and does not support SDK 6.
Foundry authenticates WebSockets with the current user's access token. It does not use OpenAI's client-secret endpoint. See realtime setup and live results for the browser flow and the manual test command.
Examples
Runnable examples cover text, streaming, tool calls, and more.
Copyright 2026 SHPIT LLC. Apache-2.0.
