Vercel AI SDK
The Vercel AI SDK works against ai& through the @ai-sdk/openai provider with a custom base URL.
npm install ai @ai-sdk/openaiimport { createOpenAI } from "@ai-sdk/openai";
export const aiand = createOpenAI({ baseURL: "https://api.aiand.com/v1", apiKey: process.env.AIAND_API_KEY,});Generate text
Section titled “Generate text”import { generateText } from "ai";import { aiand } from "./client";
const { text } = await generateText({ model: aiand("openai/gpt-oss-120b"), prompt: "Tell me a haiku about Tokyo.",});
console.log(text);Stream to the browser (Next.js App Router)
Section titled “Stream to the browser (Next.js App Router)”import { streamText } from "ai";import { aiand } from "@/lib/aiand";
export async function POST(req: Request) { const { messages } = await req.json(); const result = streamText({ model: aiand("openai/gpt-oss-120b"), messages, }); return result.toDataStreamResponse();}"use client";import { useChat } from "ai/react";
export default function Page() { const { messages, input, handleInputChange, handleSubmit } = useChat(); return ( <form onSubmit={handleSubmit}> {messages.map((m) => ( <div key={m.id}>{m.role}: {m.content}</div> ))} <input value={input} onChange={handleInputChange} /> </form> );}import { tool } from "ai";import { z } from "zod";
const result = await generateText({ model: aiand("openai/gpt-oss-120b"), tools: { getWeather: tool({ description: "Get current weather", parameters: z.object({ city: z.string() }), execute: async ({ city }) => `Sunny in ${city}, 22°C`, }), }, prompt: "What's the weather in Tokyo?",});