Vercel AI SDK
The Vercel AI SDK reaches Kiln through its OpenAI-compatible provider package, which is the one to install — not @ai-sdk/openai, whose defaults are tied to OpenAI's own service.
Install
bash
npm install ai @ai-sdk/openai-compatibleConnect
javascript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";
const kiln = createOpenAICompatible({
name: "kiln",
baseURL: "https://api.bricksum.com/v1",
apiKey: process.env.KILN_API_KEY, // sk-bk-...
});
const { textStream } = streamText({
model: kiln("qwen3-32b"),
prompt: "Write a haiku about kilns.",
maxOutputTokens: 800,
});
for await (const chunk of textStream) process.stdout.write(chunk);What differs on Kiln
- Use the openai-compatible provider createOpenAICompatible takes the base URL and the key as they are. The @ai-sdk/openai provider assumes OpenAI's endpoint layout and model IDs, so it is the wrong package here even though Kiln speaks the same wire format.
- maxOutputTokens, not max_tokens The SDK spells the output budget maxOutputTokens and forwards it as max_tokens. Reasoning tokens are billed inside that budget, so leave room or the stream ends before any text arrives. The example sends 800, a starting value not measured on this model — if the text comes back empty with finishReason 'length', raise it.
The base URL, authentication, the request parameters every endpoint shares, the response envelope, streaming and the error codes are the same whichever SDK you use. They are documented once on the API Reference. The calls above land on Chat completions. The model ID has to be one the API is serving right now; how to list those, and what to do when an ID is not among them, is on Models. What this model does not support, whatever SDK sends it, is listed under Migrating from OpenAI.
Note
Snippets on this page were run against the Kiln API on 2026-09-21 with ai 7.0.107, @ai-sdk/openai-compatible 3.0.53. Not verified: That run was on gpt-oss-120b; the page now names qwen3-32b, which it has not yet been re-run against. Only the streaming call above was run. The SDK's tool calling and structured output were not exercised against Kiln.