DeepSeek and Moonshot Request Shaping Requirements in OpenClaude

OpenClaude applies provider-specific request shaping to DeepSeek and Moonshot (Kimi) through base URL overrides, model defaults, reasoning effort normalization, and token cap enforcement.

OpenClaude treats DeepSeek and Moonshot as OpenAI-compatible providers, but each requires precise request shaping to ensure downstream API compatibility. This guide breaks down the specific shaping requirements implemented in the OpenClaude source code.

Base URL and Model Defaults

Both providers override the generic OPENAI_BASE_URL with provider-specific endpoints. In src/utils/providerFlag.ts, lines 649-657 automatically set the correct base URL and fallback model when the provider flag is applied:

  • DeepSeek: https://api.deepseek.com/v1 with default model deepseek-v4-pro
  • Moonshot: https://api.moonshot.ai/v1 with default model kimi-k2.6

These defaults are verified in src/utils/providerProfiles.test.ts (lines 3014-3022), which confirms the preset configurations load correctly for each provider.

Reasoning Effort Normalization

The generic --effort flag requires translation to provider-specific values. The normalizeDeepSeekReasoningEffort function in src/utils/effort.ts (lines 179-210) handles this mapping—for example, converting high effort to "max" for DeepSeek-compatible providers.

Moonshot inherits this normalization path because the shim marks Moonshot models as DeepSeek-compatible, ensuring consistent effort handling across both providers.

Thinking Toggle and reasoning_content Field

DeepSeek and Moonshot require the reasoning_content field on assistant messages when "thinking" mode is enabled. The OpenAI shim injects or removes this field based on user configuration.

Integration tests in src/services/api/openaiShim/requestExecutor.integration.test.ts verify this behavior:

  • Lines 3601-3605 confirm DeepSeek sends the thinking toggle with normalized reasoning effort
  • Lines 3285-3287 verify DeepSeek echoes reasoning_content on assistant tool-call messages

Moonshot inherits identical behavior through the same test coverage.

Maximum Output Token Caps

DeepSeek enforces hard caps on max_tokens—for example, 8192 tokens for deepseek-v4-flash. The shim trims requests exceeding provider limits. This is confirmed in src/utils/context.test.ts (lines 194-196), which validates that deepseek-v4-flash respects the direct API maximum output cap.

Moonshot applies analogous caps through the same request-shaping pipeline.

Cache Field Remapping

Provider-specific cache metrics (prompt_cache_hit_tokens, etc.) are normalized to generic OpenAI fields for consistent downstream reporting. The src/services/api/cacheMetrics.ts file (lines 41-47) implements this remapping for DeepSeek-compatible providers, including Moonshot.

Provider Detection

The providerDiscovery utilities in src/utils/providerDiscovery.ts (lines 237-239) detect DeepSeek and Moonshot model names by scanning for "deepseek" or "moonshot" substrings in the model identifier. This enables automatic shaping without explicit user configuration.

Practical Usage Examples

Both providers work with standardized OpenClaude commands that automatically apply all shaping requirements:


# DeepSeek with high reasoning effort

openclaude --provider deepseek \
           --model deepseek-v4-pro \
           --effort high \
           "Summarize the latest research on quantum computing"

# Moonshot with medium reasoning effort

openclaude --provider moonshotai \
           --model kimi-k2.6 \
           --effort medium \
           "Generate a Dockerfile for a Node.js app"

Each command automatically:

  • Sets OPENAI_BASE_URL to the provider's endpoint
  • Maps --effort to reasoning_effort (e.g., high → "max")
  • Injects reasoning_content when thinking mode is active
  • Clamps max_tokens to provider maximums

Core Source Files for Request Shaping

File Purpose
src/utils/providerFlag.ts Applies provider flags, injects base URLs and default models
src/utils/providerProfiles.test.ts Validates DeepSeek/Moonshot preset defaults
src/utils/effort.ts Normalizes effort flags to reasoning_effort values
src/utils/providerDiscovery.ts Detects provider from model name strings
src/services/api/openaiShim/requestPreparation.ts Assembles OpenAI-compatible request shaping
src/services/api/openaiShim/requestExecutor.integration.test.ts Integration tests for thinking toggle, effort, token caps
src/services/api/cacheMetrics.ts Maps provider cache fields to generic schema
src/utils/context.test.ts Verifies max-output token enforcement

Summary

  • Base URL override: Each provider receives its specific endpoint via providerFlag.ts
  • Default models: deepseek-v4-pro and kimi-k2.6 are injected when users don't specify
  • Effort normalization: The --effort flag maps to reasoning_effort through normalizeDeepSeekReasoningEffort
  • Thinking mode: reasoning_content field is managed automatically for assistant messages
  • Token caps: Hard limits are enforced per model via the shaping pipeline
  • Cache metrics: Provider-specific fields normalize to generic OpenAI equivalents

Frequently Asked Questions

How does OpenClaude detect whether to use DeepSeek or Moonshot shaping?

OpenClaude detects providers through src/utils/providerDiscovery.ts, which checks model name strings for "deepseek" or "moonshot" substrings. The --provider flag also triggers explicit shaping rules in providerFlag.ts that set the correct base URL and defaults.

What happens if I specify a custom model with DeepSeek or Moonshot?

The shaping pipeline still applies base URL, effort normalization, and token cap enforcement based on the detected provider. Custom model names are passed through after provider detection identifies the API endpoint requirements.

Why does Moonshot use DeepSeek-compatible shaping for reasoning effort?

Moonshot models are marked as DeepSeek-compatible in the OpenClaude architecture, so they share the normalizeDeepSeekReasoningEffort normalization path. This design reduces code duplication while ensuring consistent behavior across providers with similar API structures.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →