An OpenAI-compatible API backed by the Palantir AIP LLM Proxy.
git clone https://github.com/hazelcaffe/paip-openai-api
cd paip-openai-api
bun install
cp .env.example .envConfigure .env:
PALANTIR_AIP_URL=https://example.palantirfoundry.com
PALANTIR_AIP_API_TOKEN=your-foundry-token
# Optional. When set, clients must send Authorization: Bearer <API_KEY>.
API_KEY=
HOST=0.0.0.0
PORT=3000Start the server:
bun run startFor development with automatic reload:
bun run devOpenAPI documentation is available at http://localhost:3000/docs.
Palantir credentials are server credentials. Configure them once on the API server with PALANTIR_AIP_URL and PALANTIR_AIP_API_TOKEN; clients must not receive or submit those credentials.
API_KEY is an optional credential for this gateway:
- When
API_KEYis set, clients sendAuthorization: Bearer <API_KEY>. - When
API_KEYis unset,/v1/*is unauthenticated.
The gateway replaces the client authorization header with the Foundry token before contacting Palantir.
Use a model ID from GET /v1/models (e.g. gpt-5.5, claude-opus-4.8, etc.)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.PAIP_OPENAI_API_KEY,
baseURL: "http://localhost:3000/v1"
});
const completion = await client.chat.completions.create({
model: "claude-opus-4.8",
messages: [
{
role: "user",
content: "Explain zero data retention in one paragraph."
}
]
});
console.log(completion.choices[0]?.message.content);The Responses API is also supported:
const response = await client.responses.create({
model: "gemini-3.1-pro",
input: "Write a concise release note."
});
console.log(response.output_text);| Method | Path | Description |
|---|---|---|
GET |
/v1/models |
Lists models |
POST |
/v1/chat/completions |
OpenAI Chat Completions-compatible API |
POST |
/v1/responses |
OpenAI Responses-compatible API |
POST |
/v1/embeddings |
Foundry OpenAI embeddings |
GET |
/health |
Health check |
GET |
/docs |
OpenAPI documentation |
Example:
curl http://localhost:3000/v1/chat/completions \
-H "Authorization: Bearer $PAIP_OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.5",
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}'- OpenAI models use Foundry's OpenAI endpoints directly, preserving native request fields, response fields, tool calls, and token streaming.
- Anthropic models are translated to the Anthropic Messages endpoint.
- Gemini models are translated to the Google
generateContentendpoint. - OpenAI-style function tools, system messages, text, and common image inputs are adapted for Anthropic and Gemini.
- For adapted providers,
stream: truereturns valid SSE framing after the provider response completes. It is not token-by-token streaming. attribution,traceparent, andtracestaterequest headers are forwarded to Foundry.
The supplied model catalog contains generation models but no embedding model. For /v1/embeddings, pass the embedding model RID from Foundry Model Catalog as the model value.
Requests accept:
- The public model ID, such as
gpt-5.5,claude-opus-4.8, orgemini-3.1-pro - The full Foundry model RID
The current catalog includes models like GPT 5.5, Claude Opus 4.8, Gemini 3.1 Pro, and more. For a full list, check src/models.ts.
xAI and other models listed in the Model Catalog are not available as they cannot be queried from the LLM proxy.
bun run typecheck
# Requires .env to be properly configured
bun test