zephyrcode
v3.0.0
Published
Official JavaScript SDK for ZephyrCode — the AI coding agent platform
Downloads
1,113
Maintainers
Readme
ZephyrCode JavaScript SDK
Official JavaScript SDK for ZephyrCode — the AI coding agent platform
Installation
npm i zephyrcodeNote: This is a closed-source, proprietary SDK. There is no public repository. For support, email [email protected].
Quickstart
1. Get an API key
Create one at zephyrcode.space-z.ai/apikey. Your key will look like:
zephyr-yourname-aBcD123eFgH456...2. Stream a chat completion
const { ZephyrCode } = require("zephyrcode");
const client = new ZephyrCode({ apiKey: "zephyr-yourname-xxx" });
(async () => {
for await (const chunk of client.chat.stream({
message: "Build a React login form with Tailwind CSS",
model: "z-code-ultra",
mode: "code",
})) {
if (chunk.type === "content") {
process.stdout.write(chunk.delta);
} else if (chunk.type === "done") {
console.log(`\n\n✅ Done — tools used: ${chunk.toolsUsed}`);
}
}
})();3. Non-streaming response
const response = await client.chat.create({
message: "Explain async/await in JavaScript",
model: "z-code-pro",
});
console.log(response.content);
console.log(`Reasoning steps: ${response.reasoning.length}`);
console.log(`Tool calls: ${response.toolCalls.length}`);API Reference
new ZephyrCode({ apiKey, baseUrl, timeout })
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| apiKey | string | required | Your zephyr-{username}-{secret} key |
| baseUrl | string | https://zephyrcode.space-z.ai | API base URL |
| timeout | number | 60000 | Request timeout in ms |
client.chat.stream(params) — AsyncIterable
Stream a chat completion as Server-Sent Events.
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| message | string | — | A single user message |
| messages | Message[] | — | Full conversation history |
| model | string | "z-code-ultra" | Model ID |
| mode | string | "code" | Mode |
| thinking | boolean | true | Enable extended reasoning |
| projectContext | object | — | {language, framework, files} |
Yields event objects with .type:
| Type | Description |
|------|-------------|
| meta | Stream start — model + mode info |
| plan | Task decomposition with steps |
| reasoning | Chain-of-thought chunk |
| tool_call | Agent invokes a tool |
| tool_result | Structured tool output |
| content | Markdown content delta (.delta) |
| done | Terminal event with stats |
| error | Fatal error (throws StreamError) |
client.chat.create(params) → Promise<ChatResponse>
Same parameters as .stream(), returns { content, model, mode, toolsUsed, fallbackUsed, reasoning, toolCalls, plan }.
client.tts.create({ text, voice, speed, translate, targetLanguage }) → Promise<TTSResponse>
const audio = await client.tts.create({
text: "Hello, welcome to ZephyrCode!",
voice: "rachel",
speed: 1.0,
});
require("fs").writeFileSync("welcome.wav", audio.audio);client.apikeys — API Key Management
const keys = await client.apikeys.list();
const newKey = await client.apikeys.create({
name: "Production",
permissions: "all", // "all", "restricted", "readonly"
expiration: "60d", // "1d", "3d", "7d", "21d", "60d", "never"
credit: 100.0,
project: "My App",
});
await client.apikeys.revoke(newKey.id);
await client.apikeys.delete(newKey.id);client.projects — Project Management
const projects = await client.projects.list();
const project = await client.projects.create("My App");
await client.projects.delete(project.id);client.models — Model Information
const models = await client.models.list();
models.forEach((m) => console.log(`${m.id} — ${m.label}`));Models
| Model | ID | Best for |
|-------|----|----------|
| Z Code Ultra | z-code-ultra | Frontier reasoning, multi-file refactors |
| Z Code Pro | z-code-pro | Everyday coding, quick fixes |
| Z Code Local | z-code-local | On-device, privacy-first |
Error Handling
const { ZephyrCode, AuthenticationError, RateLimitError, APIError, StreamError } = require("zephyrcode");
try {
const response = await client.chat.create({ message: "Hello" });
} catch (e) {
if (e instanceof AuthenticationError) {
console.log("Invalid API key");
} else if (e instanceof RateLimitError) {
console.log(`Rate limited. Retry after ${e.retryAfter}s`);
} else if (e instanceof APIError) {
console.log(`API error (${e.statusCode}): ${e.message}`);
} else if (e instanceof StreamError) {
console.log(`Stream error: ${e.message}`);
}
}Automatic Retries
The SDK automatically retries on 502, 503, 504 status codes and connection errors — up to 3 times with exponential backoff (1s, 2s, 4s). This handles intermittent gateway errors transparently.
ESM Import
import { ZephyrCode } from "zephyrcode";CommonJS Require
const { ZephyrCode } = require("zephyrcode");License
Proprietary © ZephyrCode Labs. This SDK is closed-source. All rights reserved.
Links
- Documentation: zephyrcode.space-z.ai/docs
- API Keys: zephyrcode.space-z.ai/apikey
- Support: [email protected]
