cacr92/wereply
Overview
This skill provides practical guidance and patterns for integrating the DeepSeek chat API into an application. It covers HTTP client configuration, streaming and non-streaming response handling, robust error classification and retry strategies, and secure API key management. The guidance focuses on connection pooling, streaming SSE processing, and parsing generated suggestions for a chat reply assistant.
How this skill works
The skill explains how to configure a reusable HTTP client with connection pooling and timeouts, authenticate using a Bearer API key, and send chat completion requests. It shows both blocking JSON responses and Server-Sent Events (streaming) handling, including chunk parsing and invoking callbacks for incremental UI updates. Error classification and exponential backoff retries are provided to make calls resilient, and secure API key storage via system keychain is recommended.
When to use it
- Integrating DeepSeek for automated reply suggestions or chat completions.
- When you need streaming partial outputs to update a UI in real time.
- When you want efficient HTTP usage with connection pooling for high throughput.
- When you need resilient calls with retry/backoff handling for transient failures.
- When you must securely store and retrieve DeepSeek API keys.
Best practices
- Reuse a single HTTP client instance across the app to leverage connection pooling and reduce latency.
- Set sensible timeouts: separate connect timeout and overall request timeout to avoid stuck requests.
- Enable streaming only when you need partial results; handle SSE parsing and the [DONE] sentinel safely.
- Classify errors (401, 429, 5xx, timeouts) and only retry retryable cases with exponential backoff and an upper cap.
- Store API keys in the system keychain with an environment variable fallback for CI or containerized deployments.
Example use cases
- Generate three short WeChat reply suggestions from chat context and a style prompt, then parse numbered or newline-separated outputs.
- Stream model output to a frontend: emit chunks as they arrive so the UI shows progressive suggestions.
- Implement a background task that calls DeepSeek with a pooled HTTP client and retries on transient network errors.
- Securely read the DeepSeek API key from keychain in a desktop app and fall back to environment variables for automated tests.
FAQ
Use streaming when you want incremental updates to the UI or lower first-byte latency. Use non-streaming JSON when you prefer a simple request/response flow and full content is needed at once.
How do I decide retryable errors?
Treat network timeouts, connection errors, 429 rate limits, and 5xx server errors as retryable. Do not retry authentication failures (401) or client-side validation errors.
10 skills
This skill helps you integrate the DeepSeek API with a robust HTTP client, manage API keys, streaming responses, and retry strategies.
This skill helps you design consistent API interfaces and DTOs with unified ApiResponse, camelCase fields, and validation at command boundaries.
This skill helps you design and enforce robust testing strategies for Rust and front-end components, guiding unit, integration, and TDD practices.
This skill guides you through test-driven development cycles, ensuring 80%+ coverage via red-green-refactor, with tests, code, and refactor steps.
This skill guides secure review of desktop apps, ensuring key management, input validation, SQL safety, and logging hygiene to protect data.
This skill assists in implementing and wiring Tauri commands, Rust backends, and frontend bindings to enable seamless tauri integration.
This skill performs a full merge into the main branch, then removes all non-base branches locally and remotely.
This skill helps you review code for Rust, React, and databases, identifying risks, regressions, and incorrect typings to improve reliability.
This skill helps you refactor Python code by applying small, verifiable steps that improve clarity and maintain functionality.
This skill helps you accelerate React and TypeScript frontends by guiding component, hook, and Ant Design integration while enforcing best practices.