Skip to main content
The Vercel AI SDK works with Deepshi through its OpenAI-compatible provider. Point the provider at the Deepshi base URL and key.

Setup

npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

const deepshi = createOpenAICompatible({
  name: "deepshi",
  baseURL: "https://api.deepshi.ai/v1",
  apiKey: process.env.DEEPSHI_API_KEY,
});

const { text } = await generateText({
  model: deepshi("deepshi-3.0"),
  prompt: "Write a haiku about the sea.",
});

console.log(text);

Streaming

Use streamText to render tokens as they arrive, which is ideal for chat UIs:
import { streamText } from "ai";

const result = streamText({
  model: deepshi("deepshi-3.0"),
  prompt: "Explain backpropagation.",
});

for await (const chunk of result.textStream) {
  process.stdout.write(chunk);
}
Use any model id from the catalog, such as deepshi-3.0 for reasoning. See Streaming for how streaming works at the API level.