Vercel AI SDK
Use bInference as an OpenAI-compatible provider in the AI SDK.
Install the OpenAI-compatible provider:
npm i ai @ai-sdk/openai-compatibleimport { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { streamText } from "ai";
const binference = createOpenAICompatible({
name: "binference",
baseURL: "https://binference.io/api/v1",
apiKey: process.env.BINF_API_KEY,
// Adds usage to streamed answers, with what each call cost.
includeUsage: true,
});
const result = streamText({
model: binference("anthropic/claude-sonnet-5.5"),
prompt: "Write a tweet about our agent's first week.",
maxOutputTokens: 512,
});
for await (const text of result.textStream) {
process.stdout.write(text);
}Every model id from Models works with binference("..."). Tools, structured output and multi-step agents work as they do with any provider.