Skip to content
All docs

Code

JavaScript and TypeScript

The official openai package works in Node, Bun, Deno and the browser. Change the base URL and the key.

Checked 26 October 2026

Install and connect

Shell
npm install openai
export NOKEEP_API_KEY="sk-nokeep-test"  # your own key once it connects
client.ts
import OpenAI from "openai"

const client = new OpenAI({
  baseURL: "https://nokeep.ai/v1",
  apiKey: process.env.NOKEEP_API_KEY,
})

Send and stream

const reply = await client.chat.completions.create({
  model: "deepseek-v4.1-flash-uncensored",
  messages: [{ role: "user", content: "Name three good names for a tavern." }],
})
console.log(reply.choices[0].message.content)

In the browser

The API allows calls from any web page. The SDK refuses to run in a browser unless you pass dangerouslyAllowBrowser: true, because a key in a page can be read by anyone who opens it. Do it only with a key the user types in themselves, or with the free test key.

Errors and extra fields

TypeScript
import OpenAI from "openai"

try {
  await client.chat.completions.create({
    model: "deepseek-v4.1-flash-uncensored",
    messages,
    // Fields the SDK's types don't name pass through as they are:
    // @ts-expect-error min_p isn't in OpenAI's types
    min_p: 0.05,
  })
} catch (error) {
  if (error instanceof OpenAI.APIError) console.log(error.status, error.code)
}