SDK
Call the gateway
There is no published Conifer SDK. The official OpenAI and Anthropic packages are the client.
Mint a key at the console. Store it as CONIFER_API_KEY. Point the client at https://api.conifer.build. That is the whole integration.
terminal
export CONIFER_API_KEY='sk-conifer-…'terminal
npm install openairoute.ts
import OpenAI from "openai";
export function conifer() {
const apiKey = process.env.CONIFER_API_KEY;
if (!apiKey) {
throw new Error("CONIFER_API_KEY is missing. Set it before calling the gateway.");
}
return new OpenAI({
baseURL: process.env.OPENAI_BASE_URL ?? "https://api.conifer.build/v1",
apiKey,
});
}
export async function POST(req: Request) {
const res = await conifer().chat.completions.create({
model: "claude-haiku-4-5",
max_tokens: 1024,
messages: [{ role: "user", content: "three names for a build cache" }],
});
return Response.json({ content: res.choices[0].message.content });
}Which path
| Path | Use it when | |
|---|---|---|
| Official OpenAI SDK | Chat completions, Responses, streaming, tools. The recommended client. | TypeScript |
| Official Anthropic SDK | Messages wire only. Anthropic model ids. Prompt cache breakpoints. | Python |
| Env drop-in | Existing OpenAI or Anthropic code. Set two variables. Change no source. | Replace your provider key |
| curl | A one-off, a script, or a language with no SDK yet. | API reference |
| The CLI | Local models, serve a door, or register Azure as a machine endpoint. | Command reference |
Drop-in
If the project already constructs an OpenAI or Anthropic client from environment variables, set these and leave the code alone:
terminal
export OPENAI_BASE_URL=https://api.conifer.build/v1
export OPENAI_API_KEY=$CONIFER_API_KEYterminal
export ANTHROPIC_BASE_URL=https://api.conifer.build
export ANTHROPIC_API_KEY=$CONIFER_API_KEYThe Anthropic base URL has no /v1 suffix. The OpenAI one does. Replace your provider key lists what does not carry over.
Python is the same idea
terminal
pip install openaiapp.py
from openai import OpenAI
import os
client = OpenAI(
base_url=os.environ.get("OPENAI_BASE_URL", "https://api.conifer.build/v1"),
api_key=os.environ["CONIFER_API_KEY"],
)
res = client.chat.completions.create(
model="claude-haiku-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "three names for a build cache"}],
)
print(res.choices[0].message.content)The Anthropic package talks to the Messages wire:
messages.py
from anthropic import Anthropic
import os
client = Anthropic(
base_url=os.environ.get("ANTHROPIC_BASE_URL", "https://api.conifer.build"),
api_key=os.environ["CONIFER_API_KEY"],
)
res = client.messages.create(
model="claude-haiku-4-5",
max_tokens=1024,
messages=[{"role": "user", "content": "three names for a build cache"}],
)
print(res.content)No first-party package
There is no npm install @conifer/sdk and no pip install conifer. Do not add one. The gateway speaks the OpenAI and Anthropic wires; the official clients already know those wires.