LLM

Implement LLM chat completions with multi-turn conversations using the z-ai-web-dev-sdk.

Updated Jul 11, 2026
One-click install
npx skills add https://github.com/mukaddam-ali/Anadolu-Kitchen --skill llm-mukaddam-ali
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: LLM
Source: https://github.com/mukaddam-ali/Anadolu-Kitchen/tree/main/skills/LLM
Command: npx skills add https://github.com/mukaddam-ali/Anadolu-Kitchen --skill llm-mukaddam-ali

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires z-ai-web-dev-sdk, and includes scripts (resource) components.

What problem does it solve? Building conversational AI features like chatbots, assistants, and text generation requires managing message history, system prompts, and API calls. This Skill provides ready-to-use patterns for implementing LLM chat completions with the z-ai-web-dev-sdk, including conversation management, error handling, and context control. ## Core Features & Use Cases - Chat Completions: Send single-turn questions or multi-turn conversations with system prompts and optional chain-of-thought reasoning. - Conversation Management: Maintain message history, trim context to avoid token limits, and reset sessions programmatically. - CLI and SDK Modes: Use the z-ai CLI for quick one-off queries or the SDK for production web application integration. - Use Case: Build a customer support chatbot with an Express.js API that remembers each user's conversation history across requests and responds with context-aware answers. ## Quick Start Use the LLM skill to create a chat completion that answers a user question with a custom system prompt via the z-ai-web-dev-sdk.

Frequently Asked Questions about LLM

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a chat completion with z-ai-web-dev-sdk?

Call ZAI.create() to initialize the SDK, then use zai.chat.completions.create with a messages array containing an assistant system prompt and a user message. The response text is available at completion.choices[0].message.content.

How to maintain multi-turn conversation history in a chatbot?

Store messages in an array starting with the system prompt, append each user message and assistant response, and pass the full array to each completion call. Trim older messages when the history exceeds your limit to avoid token constraints.

Can I use z-ai-web-dev-sdk in client-side browser code?

No, the SDK must be used in backend code only. Import and call it from server-side routes or API handlers, never from client-side JavaScript, to protect credentials and ensure proper operation.

When should I use the z-ai CLI instead of the SDK?

Use the CLI for quick one-off questions, simple automation scripts, and prompt testing with commands like z-ai chat --prompt. Use the SDK for multi-turn conversations, web application integration, and production chat workflows.

Why does my chat completion return an empty response?

Empty responses occur when completion.choices[0].message.content is missing or blank. Validate the response before using it, and implement retry logic with exponential backoff to handle transient API failures.