@nyrra/foundry-ai
Version:
Thin Palantir Foundry provider adapters and model catalog for the Vercel AI SDK.
210 lines (154 loc) • 11.4 kB
text/mdx
---
title: Foundry AI
description: Learn how to use @nyrra/foundry-ai to access Palantir Foundry LLM proxy endpoints from the AI SDK.
---
# Foundry AI
The [`@nyrra/foundry-ai`](https://www.npmjs.com/package/@nyrra/foundry-ai) community provider routes AI SDK language-model and OpenAI embedding requests through Palantir Foundry's provider-compatible proxy endpoints.
Use it when you want local development and deployed server workloads to call secure/private Foundry endpoints while keeping AI SDK application code and provider-specific request shapes.
## Key Features
- Secure/private Foundry proxy endpoints for local development and deployed server workloads
- OpenAI, Anthropic, and Google adapters with one shared alias-to-RID catalog
- Application-level multi-provider routing with AI SDK `createProviderRegistry`
- Explicit Foundry compatibility handling for OpenAI and Google proxy behavior
## Version Compatibility
| Provider Version | AI SDK Version | Status |
|---|---|---|
| 0.x | v6 with provider packages v3 | Preview |
| 0.x | v7 stable, or the v7.0 beta line from `7.0.0-beta.187`, with provider packages v4 from the declared beta floors | Preview |
Use provider packages from the matching AI SDK generation. Applications remain free to pin exact versions inside the supported ranges.
## Setup
Install the package, `ai`, and only the provider peer dependency you need:
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
<Tab>
<Snippet text="pnpm add @nyrra/foundry-ai ai @ai-sdk/openai" dark />
</Tab>
<Tab>
<Snippet text="npm install @nyrra/foundry-ai ai @ai-sdk/openai" dark />
</Tab>
<Tab>
<Snippet text="yarn add @nyrra/foundry-ai ai @ai-sdk/openai" dark />
</Tab>
<Tab>
<Snippet text="bun add @nyrra/foundry-ai ai @ai-sdk/openai" dark />
</Tab>
</Tabs>
Swap `@ai-sdk/openai` for `@ai-sdk/anthropic` or `@ai-sdk/google` when you use those provider entrypoints. Install multiple peers only when your app actually routes to multiple providers.
## Environment
Set the Foundry enrollment URL and token in your server runtime:
```bash
FOUNDRY_URL=https://your-stack.palantirfoundry.com
FOUNDRY_TOKEN=your-token
FOUNDRY_ATTRIBUTION_RID=
```
`FOUNDRY_ATTRIBUTION_RID` is optional.
## Provider instance
Import the root config helper plus the provider-specific subpath you need:
```ts
import { loadFoundryConfig } from '@nyrra/foundry-ai';
import { createFoundryOpenAI } from '@nyrra/foundry-ai/openai';
const openai = createFoundryOpenAI(loadFoundryConfig());
```
Other entrypoints:
- `@nyrra/foundry-ai/anthropic`
- `@nyrra/foundry-ai/google`
## Language models
Model IDs can be either:
- a known alias such as `gpt-5.6-terra`, `claude-opus-5`, or `gemini-3.6-flash`
- a raw Foundry language model RID such as `ri.language-model-service..language-model.gpt-5-2`
Known aliases resolve through the package catalog. Raw RIDs pass through unchanged when you call a provider factory directly.
## Example
```ts
import { loadFoundryConfig } from '@nyrra/foundry-ai';
import { createFoundryOpenAI } from '@nyrra/foundry-ai/openai';
import { generateText } from 'ai';
const openai = createFoundryOpenAI(loadFoundryConfig());
const { text } = await generateText({
model: openai('gpt-5-mini'),
prompt: 'Summarize why Foundry model aliases are useful.',
});
console.log(text);
```
## OpenAI embeddings
```ts
import { embed } from 'ai';
const { embedding } = await embed({
model: openai.embeddingModel('text-embedding-3-small'),
value: 'Embed this text through Foundry.',
});
```
The OpenAI provider provides typed aliases for `text-embedding-3-small` and `text-embedding-3-large`, while other plain OpenAI model strings pass through unchanged. Embeddings do not use Foundry RID routing. Anthropic and Google embeddings remain unsupported.
## Multi-provider routing
The package does not export a registry helper. Compose one in application code with AI SDK `createProviderRegistry`:
```ts
import { loadFoundryConfig } from '@nyrra/foundry-ai';
import { createFoundryAnthropic } from '@nyrra/foundry-ai/anthropic';
import { createFoundryOpenAI } from '@nyrra/foundry-ai/openai';
import { createProviderRegistry } from 'ai';
const config = loadFoundryConfig();
const registry = createProviderRegistry({
anthropic: createFoundryAnthropic(config),
openai: createFoundryOpenAI(config),
});
```
## Foundry-specific behavior
- OpenAI traffic always uses Foundry-safe compatibility defaults where required.
- `providerOptions.openai.store = true` throws before the request is sent.
- Known OpenAI reasoning aliases automatically get `providerOptions.openai.forceReasoning = true` unless the caller already set it.
- Google support is backed by Foundry's beta Google-compatible proxy.
- OpenAI embeddings are supported; Anthropic and Google embedding methods remain unsupported.
## Model Capabilities
These tables reflect the latest checked-in harness capability snapshot for one Foundry stack, not raw enrollment metadata. The package catalog derives flags such as `supportsVision` from Foundry `inputTypes`, so a model can advertise a capability in metadata even when the current stack still fails that harness check. `-` means the capability is intentionally not asserted or is out of scope for the current stack.
### OpenAI
| Model | Text | Stream | Structured | Tools | Vision | Reasoning |
|---|---|---|---|---|---|---|
| `gpt-5.4-nano` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-5.4-mini` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-5.4` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-5.2` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-5.1-codex-mini` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gpt-5.1-codex` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gpt-5.1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gpt-5-nano` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-5-mini` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-5-codex` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gpt-5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-4.1-nano` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gpt-4.1-mini` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gpt-4.1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `o4-mini` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `gpt-4o` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `o3` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> |
### Anthropic
| Model | Text | Stream | Structured | Tools | Vision | Reasoning |
|---|---|---|---|---|---|---|
| `claude-sonnet-4.6` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
| `claude-opus-4.6` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> |
| `claude-sonnet-4.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `claude-opus-4.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| `claude-haiku-4.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `claude-opus-4.1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `claude-sonnet-4` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
| `claude-opus-4` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `claude-3.7-sonnet` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
| `claude-3.5-haiku` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
### Google
| Model | Text | Stream | Structured | Tools | Vision | Reasoning |
|---|---|---|---|---|---|---|
| `gemini-3.1-pro` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gemini-3.1-flash-lite` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gemini-3-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gemini-2.5-pro` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gemini-2.5-flash-lite` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
| `gemini-2.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | - |
These tables summarize the latest checked-in harness snapshot. For row-level notes and durations, see the full harness capability results.
## Limitations
- Verified today for env-based server usage.
- Not yet validated end to end in Palantir TSv1/TSv2 standalone functions.
- Not yet validated with `@osdk/client` / `PlatformClient` fetch wiring.
- Embeddings, image generation, speech, transcription, video, and rerank methods are not exposed by this package yet.
## Additional resources
- [Package README](https://github.com/shpitdev/foundry-ai/tree/main/packages/foundry-ai#readme)
- [Usage guide](https://github.com/shpitdev/foundry-ai/blob/main/packages/foundry-ai/docs/usage.md)
- [Model support guide](https://github.com/shpitdev/foundry-ai/blob/main/packages/foundry-ai/docs/model-support.md)
- [Harness capability results](https://github.com/shpitdev/foundry-ai/blob/main/packages/foundry-ai/docs/harness-capability-results.md)
- [Palantir LLM-provider compatible APIs](https://www.palantir.com/docs/foundry/aip/llm-provider-compatible-apis/)