Skip to main content

Crate codewhale_models

Crate codewhale_models 

Source
Expand description

API request/response models for DeepSeek and OpenAI-compatible endpoints.

Modules§

auto_route_evidence
hand_pricing
image_window
reasoning_effort_tier
schema_canonicalize
Byte-level canonicalization of JSON Schema for prefix-cache stability.
schema_sanitize
Schema sanitizer for tool input_schema before sending to provider APIs.
tool_projection
turn_classify

Structs§

CacheControl
Cache control metadata for tool definitions and blocks.
ContainerInfo
Container metadata for code-execution style server tools.
ConversationTitleConfig
ImageUrlContent
OpenAI-compatible image URL payload inside a multimodal message.
Message
A chat message with role and content blocks.
MessageDelta
Delta payload for message-level updates.
MessageRequest
Request payload handed to the model-client preparation seam.
MessageResponse
Response payload for a message request.
OpaqueReasoningState
Provider-owned reasoning continuity that is safe to replay only on the exact originating API and model. The encrypted payload is deliberately separate from readable ContentBlock::Thinking text.
SafetyCheckConfig
ServerToolUsage
Server-side tool usage counters.
SystemBlock
A structured system prompt block.
Tool
Tool definition exposed to the model.
ToolCaller
Metadata describing who invoked a tool call.
Usage
Token usage metadata for a response.

Enums§

ContentBlock
A single content block inside a message.
ContentBlockStart
Content block types used in streaming starts.
Delta
Delta events emitted during streaming responses.
Role
Who authored a message in a transcript.
StreamEvent
Streaming event types for SSE responses.
SystemPrompt
System prompt representation (plain text or structured blocks).
ToolCallKey
Identity for pairing host history without conflating a provider’s reused string with a local execution. Legacy identity cannot establish a grant.

Constants§

DEEPSEEK_V4_CONTEXT_WINDOW_TOKENS
DEFAULT_COMPACTION_TOKEN_THRESHOLD
Last-resort compaction trigger when context_window_for_model returns None (an unrecognised model id). v0.8.11 raised this from 50_000 to 102_400 (80% of LEGACY_DEEPSEEK_CONTEXT_WINDOW_TOKENS) so unknown models inherit the same late-trigger discipline as V4 instead of paying the prefix-cache hit at 5% of the V4 window. Known DeepSeek / Claude models resolve to their own scaled value via compaction_threshold_for_model (#664).
DIRECT_KIMI_K3_MAX_OUTPUT_TOKENS
Documented maximum output for the exact direct Kimi K3 API route.
INTERRUPTED_ASSISTANT_CONTEXT_PREFIX
Prefix attached to interrupted assistant output when it is replayed as context.
INTERRUPTED_ASSISTANT_ROLE
Internal role used for assistant text that was visible before a turn was interrupted.
KIMI_CODE_K3_CONTEXT_WINDOW_TOKENS
Conservative Kimi Code K3 context baseline. The membership route’s real context is plan-tier dependent (verified 2026-07-20 from https://www.kimi.com/code/docs/en/kimi-code/models): Moderato gets 256K, while Allegretto and above get up to 1M. Bare k3 therefore keeps this safe floor everywhere; higher plan entitlements must come from an explicit provider context_window configuration or fresh provider facts while preserving the k3 wire id.
KIMI_K3_CONTEXT_WINDOW_TOKENS
Kimi K3 context window on the open platform (kimi-k3 pay-as-you-go). Verified 2026-07-20 from https://platform.kimi.ai/docs/guide/kimi-k3-quickstart (1,048,576 tokens). Max output is a separate fact below and must never be conflated with this window.
KIMI_K3_DEFAULT_MAX_COMPLETION_TOKENS
Conservative K3 default generation ceiling. The direct Kimi API defaults max_completion_tokens to 131,072, while its documented route maximum is a separate exact-route fact below. Membership and neighboring routes do not inherit that direct-platform maximum.
LEGACY_DEEPSEEK_CONTEXT_WINDOW_TOKENS
Context window used only for legacy DeepSeek model IDs that do not name a newer V4 alias and do not carry an explicit *k suffix.
OUTPUT_CEILING_STOP_REASON
Stop reason recorded for a response that reported stop while its own usage shows it ran to the requested output ceiling (#6889). The Chat Completions spelling, so every existing output-limit path treats it as a length stop.

Functions§

canonical_official_deepseek_model_id
context_window_for_model
Map known models to their approximate context window sizes.
effective_muse_wire_id
Contributor tier of Muse Spark 1.2 is a distinct selectable id with its own wire model (muse-spark-1.2-contributor) and cheaper billing in exchange for training-data opt-in. Do not collapse it to the standard tier.
generation_default_for_model
has_date_snapshot_suffix
is_incomplete_stop_reason
True when the provider explicitly reported that it did not complete the response. Responses API reasons carry an incomplete: prefix so unknown future reasons cannot accidentally be accepted as a finished answer.
is_openai_gpt_56_api_model
is_output_limit_stop_reason
True when the provider ended generation because its output allowance was exhausted. Providers use several wire spellings for the same condition.
is_refusal_stop_reason
max_output_tokens_for_model
model_can_disable_thinking
model_is_openai_reasoning_family
model_reasoning_capability
Catalog-first reasoning capability. None means no catalog row and no remaining cited fallback — unknown, not “not a reasoning model”.
model_requires_thought_signatures
model_supports_reasoning
name_suffix_context_window_hint
The context window a model name’s _Nk suffix advertises, when the catalog does not already describe the model (#5441).
stop_contradicts_output_ceiling
True when a Chat Completions stop is contradicted by the provider’s own usage: the completion tokens it reported equal the output ceiling the request asked for (#6889). A finished answer leaves the allowance unfilled, so this response was cut at the ceiling, typically by reasoning that used the allowance before or during the answer.
stop_reason_detail