Bridge by Wekoya / Guides / Use the Vercel AI SDK with Bridge
Use the Vercel AI SDK with Bridge
In short: Create a provider with createOpenAI({ baseURL, apiKey }) pointed at Bridge and call bridge.chat(model) for Chat Completions. The default bridge(model) uses the Responses API, which Bridge also answers. Streaming, tools and structured output work on every model that supports them, billed in naira.
Updated
npm install ai @ai-sdk/openaiimport { createOpenAI } from "@ai-sdk/openai"
import { streamText } from "ai"
const bridge = createOpenAI({
name: "bridge",
baseURL: "https://wekoya-api.wekoya.tech/v1",
apiKey: process.env.WEKOYA_API_KEY,
})
const result = streamText({
model: bridge.chat("claude-sonnet-5-5"),
prompt: "Write a welcome message for a Lagos bakery.",
})
for await (const text of result.textStream) process.stdout.write(text)bridge.chat(model)calls Chat Completions and carries every Bridge option. Recommended.bridge(model)calls the Responses API. It works too, statelessly: the SDK sends the whole conversation each time.- Or use
createOpenAICompatiblefrom@ai-sdk/openai-compatible, which always uses Chat Completions. - Keep the key on the server, in a route handler or server action. Never in a
NEXT_PUBLIC_variable.
Common questions
Why use .chat(model) with the AI SDK?
Since AI SDK 5, openai(model) uses OpenAI's Responses API by default. Bridge answers both, but .chat(model) uses Chat Completions, which carries every Bridge option.