goldbean-client
v0.1.0
Published
Official GoldBean SDK — One client for 7 Chinese LLM providers
Maintainers
Readme
GoldBean Client SDK
One client for 7 Chinese LLM providers.
npm install goldbean-clientQuick Start
const { createClient } = require('goldbean-client');
const gb = createClient('your-api-key');
// Simple ask
const response = await gb.ask('deepseek-v4-pro', 'Explain quantum computing in 3 sentences');
console.log(response.content);
// Full chat
const result = await gb.chat({
model: 'kimi-k2.6',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Write a Python function to reverse a linked list.' }
],
maxTokens: 2000
});
console.log(result.content);
console.log(result.usage.total_tokens);Supported Providers
| Provider | Models | Endpoint |
|----------|--------|----------|
| DeepSeek | V4-Pro, V4-Flash | /ai/ds/chat, /ai/ds/flash |
| Kimi (Moonshot) | K2.6, K2.7-Code | /ai/kimi/chat, /ai/kimi/code |
| Doubao (ByteDance) | Pro, Mini, Lite | /ai/doubao/chat, /ai/doubao/mini, /ai/doubao/lite |
| Qwen (Alibaba) | Max, Turbo, Plus | /ai/qwen/chat, /ai/qwen/turbo, /ai/qwen/plus |
| Hunyuan (Tencent) | Pro | /ai/hy3/chat |
| ERNIE (Baidu) | 4.0 | /paid/baidu-llm-chat |
| GLM (Zhipu) | 4 | /ai/glm/chat |
API Key
Get your API key at goldbean-api.xyz:
- Free: 2000 calls/day without signup
- Paid: From $5 for 100 calls (no expiry)
Methods
chat(params)
Send a chat completion request.
const response = await gb.chat({
model: 'deepseek-v4-pro', // Required
messages: [ // Required
{ role: 'user', content: 'Hello' }
],
temperature: 0.7, // Optional (ignored for Kimi, fixed at 1)
maxTokens: 1000, // Optional
});ask(model, message, options)
Simple one-shot ask.
const response = await gb.ask('deepseek-v4-pro', 'What is 2+2?');getModels(provider?)
List available models.
const models = await gb.getModels(); // All models
const deepseekModels = await gb.getModels('deepseek'); // Provider-specifichealth(provider)
Check provider health.
const health = await gb.health('deepseek');Response Format
{
content: "The assistant's response text",
provider: "deepseek",
model: "deepseek-v4-pro",
usage: {
prompt_tokens: 12,
completion_tokens: 56,
total_tokens: 68
},
finishReason: "stop",
raw: { /* full API response */ }
}Error Handling
try {
const response = await gb.chat({ model: 'unknown-model', messages: [] });
} catch (err) {
console.error(err.message); // "Unknown model: unknown-model"
}Retry Logic
The SDK automatically retries on:
- 429 Too Many Requests
- 5xx Server Errors
- Network errors
Default: 2 retries with exponential backoff.
License
MIT © GoldBean
