Messages
Messages-format JSON, streaming and client-executed tools through the native Go gateway.
/v1/messagesAvailability and identity#
A bounded real-GPU canary passed JSON, SSE, a streamed tool call and its result continuation through isolated Better Auth/D1 accounts and the signed native Go gateway. Public inference remains unavailable until the production Go connection is enabled. Use an account-owned DarkSeek key as x-api-key or Authorization: Bearer, never both. Keys and web sessions share the same durable admission allowance.
Version and required fields#
Send anthropic-version: 2023-06-01, model, messages and a positive max_tokens within the Models deployment ceiling. Start with a user entry. System instructions belong in system, not a system-role message. Only text input and client-executed custom tools are accepted. Unknown/private fields, images, server tools, beta headers and cache hints are rejected.
Official client setup#
The official TypeScript SDK is contract-tested with version 1.8.0. Explicitly select the supported API date; newer SDK default dates are not silently accepted. Disable automatic generation retries and use a finite client timeout. SDK compatibility does not mean DarkSeek serves Claude models or every Anthropic feature.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.DARKSEEK_API_KEY,
baseURL: process.env.DARKSEEK_BASE_URL, // origin, without /v1
defaultHeaders: { "anthropic-version": "2023-06-01" },
maxRetries: 0,
timeout: 30000,
});
const reply = await client.messages.create({
model: "darkseek-v4.1",
messages: [{ role: "user", content: "Hello!" }],
max_tokens: 128,
thinking: { type: "disabled" },
});Streaming lifecycle#
With stream=true, read message_start, content_block_start/delta/stop, message_delta and message_stop. Text, thinking and input_json_delta blocks retain their own indexes. The final message_delta carries the stop reason and usage; successful completion requires message_stop. There is no [DONE] marker. A malformed, interrupted, oversized or backend-error stream ends with an error event and no fabricated successful terminal event.
Tools and continuation#
Define at most 64 named custom tools with object input_schema. tool_choice supports auto, any, tool plus an existing name, or none. Tool code runs in your application, never on the gateway. Return each immediately preceding tool_use ID exactly once in the next user tool_result block before generating again. Duplicate, unmatched, pending or foreign result IDs are rejected. Tool argument buffering is bounded at 2 MiB per block; this is separate from token limits.
Thinking and limits#
thinking supports disabled or adaptive. The installed backend cannot guarantee budget_tokens or display suppression; those controls are rejected. Reasoning is not an Anthropic-verifiable signed artifact. Adaptive reasoning output and parallel tool combinations still need broader physical certification. temperature and top_p are 0–1; top_k is 1–1000; at most four nonempty stop sequences, 512 messages and 512 input blocks per entry. Shared body, response, time, concurrency and daily-attempt ceilings still apply.
Errors and safe retries#
Messages errors use type=error with an error object. AuthenticationError, RateLimitError and streaming error behavior are tested with the official SDK. Keep the fixed error code and X-Request-ID; backend diagnostics and customer credentials are not forwarded. A timeout after admission consumes an attempt. Never blindly retry a generation after an ambiguous disconnect.