node-deepseek
v1.1.1
Published
Node.js client for Deepseek AI API
Downloads
61
Maintainers
Readme
Deepseek Node.js Client
A fully-featured TypeScript/Node.js client for interacting with the Deepseek AI API.
Installation
npm install node-deepseekQuick Start
import { Deepseek } from 'node-deepseek';
const client = new Deepseek({
apiKey: process.env.DEEPSEEK_API_KEY || '',
});
const response = await client.chat.createCompletion({
messages: [{ role: 'user', content: 'Hello, how are you?' }],
model: 'deepseek-chat',
});Features
- Comprehensive TypeScript support
- Streaming responses for real-time updates
- Robust error handling with detailed messages
- Full compatibility with all Deepseek models
- Automatic retries for rate-limited requests
Available Models
deepseek-chatdeepseek-chat-v2deepseek-chat-v2.5deepseek-coderdeepseek-coder-v2deepseek-coder-v2.5
API Reference
Configuration
const client = new Deepseek({
apiKey: process.env.DEEPSEEK_API_KEY || '',
});Chat Completion
const response = await client.chat.createCompletion({
messages: [{ role: 'user', content: 'Hello' }],
model: 'deepseek-chat',
temperature: 0.7,
max_tokens: 100,
});Streaming
await client.chat.streamCompletion(
{
messages: [{ role: 'user', content: 'Tell me a story' }],
model: 'deepseek-chat',
stream: true,
},
(chunk) => console.log(chunk.choices[0].delta.content),
);Error Handling
try {
const response = await client.chat.createCompletion({
messages: [{ role: 'user', content: 'Hello' }],
model: 'deepseek-chat',
});
} catch (error) {
if (error instanceof DeepseekError) {
console.error('API Error:', error.message);
}
}License
This project is licensed under the MIT License.
Contributing
We welcome contributions! Please refer to CONTRIBUTING.md for guidelines on how to contribute.
Development
Installation
npm installScripts
Run Tests
npm testRun Tests in Watch Mode
npm run test:watchRun Tests with Coverage
npm run test:coverageLint Code
npm run lintFix Linting Issues
npm run lint:fixFormat Code
npm run format
