OpenAI Node.js SDK integration
Call DeepSeek from Node.js with the OpenAI SDK
The official OpenAI Node.js SDK accepts a custom base URL. The client stays small, and switching between DeepSeek models is one string change.
Settings
- SDK
- openai (Node.js)
- Base URL
- https://tokuse.com/v1
- Model
- deepseek-flash
- Auth env
- TOKUSE_API_KEY
Setup steps
- Install the openai package.
- Read the Tokuse key from the server environment.
- Set baseURL to https://tokuse.com/v1.
- Call chat.completions.create with deepseek-flash.
- Test streaming, timeout handling, and retries before production.
Configuration
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.TOKUSE_API_KEY,
baseURL: 'https://tokuse.com/v1',
timeout: 30_000,
maxRetries: 2,
});
const response = await client.chat.completions.create({
model: 'deepseek-flash',
messages: [
{ role: 'system', content: 'Answer in one short paragraph.' },
{ role: 'user', content: 'Summarize the latest release notes.' },
],
});
console.log(response.choices[0]?.message?.content);Before production use
- Keep the Tokuse key on the server or in the tool's secret store.
- Use the base URL without appending /chat/completions.
- Verify the model alias in the current Tokuse catalog.
- Test errors, timeout behavior, and cost with a small workload first.