SDK
Install and verify
Mint a key, install the official OpenAI package, make one completion.
Done when a chat completion returns a line of text. Use TypeScript or Python. The CLI is not required.
Get an API key
Open conifer.build/console#/keys. Pay as you go unlocks minting. The key is shown once. Save it:
export CONIFER_API_KEY='sk-conifer-…'$env:CONIFER_API_KEY="sk-conifer-…"Install a client
npm install openaipip install openaiThat is the recommended SDK. The official Anthropic package is the other drop-in; see Python. There is no first-party Conifer package to install.
Point the OpenAI client at Conifer
Either pass baseURL and apiKey in code, or set the two OpenAI variables and change nothing:
export OPENAI_BASE_URL=https://api.conifer.build/v1
export OPENAI_API_KEY=$CONIFER_API_KEYCreate a route or a script
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: "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: 64,
messages: [{ role: "user", content: "Say hello from Conifer and nothing else." }],
});
return Response.json({ content: res.choices[0].message.content });
}import os
from openai import OpenAI
client = 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=64,
messages=[{"role": "user", "content": "Say hello from Conifer and nothing else."}],
)
print(res.choices[0].message.content)Run it
TypeScript is an App Router handler. Paste it into app/api/verify/route.ts, or put conifer() in lib/ and call it from the handler. Python is a script:
python test_conifer.pyYou should see a greeting. Or use curl below. A 401 is invalid_api_key (missing or wrong). A 402 is billing (insufficient_quota) or the spend cap. Errors lists the names.
Or curl
curl https://api.conifer.build/v1/chat/completions \
-H "Authorization: Bearer $CONIFER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-haiku-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "three names for a build cache"}]
}'