Code
Vercel AI SDK
Erstellen Sie mit createOpenAICompatible aus @ai-sdk/openai-compatible einen nokeep-Provider. Dann funktionieren generateText, streamText und Tools wie bei jedem AI-SDK-Modell.
Geprüft am 29. Oktober 2026
Paket installieren und Provider einrichten
npm install ai @ai-sdk/openai-compatible zod
export NOKEEP_API_KEY="sk-nokeep-test" # your own key once it connectsimport { createOpenAICompatible } from "@ai-sdk/openai-compatible"
export const nokeep = createOpenAICompatible({
name: "nokeep",
apiKey: process.env.NOKEEP_API_KEY,
baseURL: "https://nokeep.ai/v1",
includeUsage: true, // token counts on streamed replies too
})nokeep("<model id>") ergibt ein Modell. Die IDs sind deepseek-v4.1-flash-uncensored und glm-5.3-flash-uncensored: Vergleichen Sie sie unter Modelle oder lesen Sie sie aus GET /v1/models. includeUsage: true fordert Token-Zählungen auch bei gestreamten Antworten an; ohne diese Option meldet streamText keine.
generateText
import { generateText } from "ai"
import { nokeep } from "./nokeep.js"
const { text, usage } = await generateText({
model: nokeep("deepseek-v4.1-flash-uncensored"),
system: "You are a blunt editor.",
prompt: "Cut this opening line to ten words: ...",
})
console.log(text)
console.log(usage.inputTokens, usage.outputTokens)streamText
import { streamText } from "ai"
import { nokeep } from "./nokeep.js"
const result = streamText({
model: nokeep("deepseek-v4.1-flash-uncensored"),
prompt: "Tell me a story in three lines.",
})
for await (const text of result.textStream) process.stdout.write(text)
// With includeUsage on, the counts arrive once the stream ends.
console.log(await result.usage)In einem Next.js-Route-Handler geben Sie für useChat result.toUIMessageStreamResponse() zurück, für reinen Text result.toTextStreamResponse(). Eine Antwort stoppen Sie, indem Sie die Anfrage abbrechen (abortSignal); bezahlt wird, was bis dahin geschrieben wurde. Siehe Streaming.
Tool-Aufrufe
import { generateText, stepCountIs, tool } from "ai"
import { z } from "zod"
import { nokeep } from "./nokeep.js"
const { text } = await generateText({
model: nokeep("deepseek-v4.1-flash-uncensored"),
tools: {
weather: tool({
description: "Get the weather in a city",
inputSchema: z.object({ city: z.string() }),
execute: async ({ city }) => ({ city, celsius: 18 }),
}),
},
stopWhen: stepCountIs(5), // let the model call the tool, read the result and answer
prompt: "What's the weather in Lisbon?",
})
console.log(text)Beide Modelle rufen Tools auf. glm-5.3-flash-uncensored wählt selbst: toolChoice: "required" oder ein benanntes Tool ergibt einen 400, verwenden Sie daher DeepSeek, wenn ein Tool laufen muss. Siehe Tool-Aufrufe.
Denkaufwand
import { generateText } from "ai"
import { nokeep } from "./nokeep.js"
const { text, reasoningText } = await generateText({
model: nokeep("deepseek-v4.1-flash-uncensored"),
prompt: "Plan a three-act heist story in five bullet points.",
maxOutputTokens: 4000, // thinking counts toward the limit
providerOptions: { nokeep: { reasoningEffort: "high" } },
})
console.log(reasoningText) // the thinking, apart from the answer
console.log(text)Der Schlüssel unter providerOptions ist der name, den Sie dem Provider gegeben haben. Er wird unverändert als reasoning_effort gesendet. DeepSeek V4.1 Flash Uncensored antwortet sofort, außer Sie bitten es zu denken: Es akzeptiert none, low, high, max. Die eigene Option reasoning: "high" des AI SDK sendet dasselbe Feld. Siehe Denken.
Bilder (DeepSeek)
import { readFile } from "node:fs/promises"
import { generateText } from "ai"
import { nokeep } from "./nokeep.js"
const { text } = await generateText({
model: nokeep("deepseek-v4.1-flash-uncensored"),
messages: [{
role: "user",
content: [
{ type: "text", text: "What is in this picture?" },
{ type: "file", mediaType: "image/jpeg", data: await readFile("photo.jpg") },
],
}],
})
console.log(text)deepseek-v4.1-flash-uncensoredliest bis zu 10 Bilder pro Anfrage.glm-5.3-flash-uncensoredliest nur Text und antwortet mit400 unsupported_input.- Das AI SDK sendet jedes Bild innerhalb der Anfrage, als Base64. Übergeben Sie eine
URLalsdata, lädt es die Datei zuerst herunter. Eine Anfrage darf bis zu 12 MB groß sein, verkleinern Sie also große Fotos. - Bilder sind
file-Teile mit einemimage/*-Medientyp. Der ältereimage-Teil funktioniert noch, ist aber veraltet. - Andere Dateien, etwa PDFs oder Audio, werden mit
400 unsupported_inputabgelehnt. Siehe Bilder.
Stolperfallen
- `reasoning_effort` akzeptiert nur die eigenen Werte des Modells.
deepseek-v4.1-flash-uncensoredakzeptiertnone,low,high,max;glm-5.3-flash-uncensoredakzeptiertlow,high. Die Werteminimal,mediumundxhighanderer Apps werden auf die nächstliegende Stufe des Modells abgebildet (mediumalshigh,xhighalsmax, wo das Modell sie hat); jeder andere Wert ergibt400 invalid_reasoning_effort. Siehe Denken. - Felder, die ein Modell nicht akzeptiert, werden verworfen, nicht abgelehnt. Der Aufruf antwortet trotzdem, und der Antwort-Header
x-nokeep-ignorednennt, was weggelassen wurde. GLM behält nurtools,tool_choiceundreasoning_effort, daher werden seinetemperatureundresponse_formatverworfen. Siehe welche Felder jedes Modell annimmt. - `n` muss 1 sein. Für mehrere Antworten machen Sie mehrere Aufrufe.
- `@ai-sdk/openai-compatible` verwenden, nicht `@ai-sdk/openai`. Der OpenAI-Provider ruft standardmäßig
/v1/responsesauf, das nokeep nicht hat.
Fragen
Gibt es ein nokeep-Provider-Paket für das AI SDK?
Sie brauchen keins. @ai-sdk/openai-compatible ist das eigene Paket des AI SDK für OpenAI-kompatible APIs, und jede Funktion auf dieser Seite läuft darüber.
Meldet streamText die Nutzung?
Ja, wenn der Provider mit includeUsage: true erstellt wurde. await result.usage liefert dann die Token-Zählungen für den Aufruf.
Kann ich es ohne Bezahlung testen?
Ja. Nutzen Sie den Schlüssel sk-nokeep-test: Jeder Aufruf antwortet mit einer festen Zeile und kostet nichts, sodass Sie zuerst Ihre App anbinden können. Der kostenlose Testschlüssel.