DeepSeekException

Base class for all exceptions thrown by DeepSeek SDK endpoint calls.

Thrown by every endpoint extension function (chat, FIM, models, userBalance, and their streaming counterparts) when the API returns a non-2xx status. Use statusCode and the subclass type to distinguish failure modes, error to inspect the structured error payload, and headers for rate-limit or retry hints.

Example:

try {
client.chat("hello")
} catch (e: DeepSeekException.RateLimitException) {
val retryAfter = e.headers["Retry-After"]
// back off and retry
} catch (e: DeepSeekException) {
println("DeepSeek call failed with ${e.statusCode}: ${e.message}")
}

Inheritors

Types

Link copied to clipboard

Thrown for HTTP 400 — the request body or parameters are malformed.

Link copied to clipboard
object Companion
Link copied to clipboard

Thrown for HTTP 402 — the account has insufficient balance to complete the call.

Link copied to clipboard

Thrown for HTTP 500 — the DeepSeek service failed to process the request.

Link copied to clipboard

Thrown for HTTP 404 — the endpoint or model referenced by the request does not exist.

Link copied to clipboard

Thrown for HTTP 503 — the DeepSeek service is temporarily overloaded.

Link copied to clipboard

Thrown for HTTP 403 — the API key is valid but lacks permission for the resource.

Link copied to clipboard

Thrown for HTTP 429 — the client exceeded the allowed request rate.

Link copied to clipboard

Thrown for HTTP 401 — the API key is missing, invalid, or revoked.

Link copied to clipboard
class UnexpectedStatusCodeException(statusCode: Int, headers: DeepSeekHeaders, error: DeepSeekError?, message: String?) : DeepSeekException

Thrown for any non-2xx status not covered by the other subclasses.

Link copied to clipboard

Thrown for HTTP 422 — the request is syntactically valid but semantically invalid (for example, a parameter is outside its allowed range).

Properties

Link copied to clipboard
expect open val cause: Throwable?
Link copied to clipboard

Parsed error payload, or null if the body could not be decoded

Link copied to clipboard

Response headers snapshot (case-insensitive lookups)

Link copied to clipboard
expect open val message: String?
Link copied to clipboard

HTTP status code returned by the API