DIM · Dagon Inference Marketplace

Error codes

All HTTP errors from the gateway and the indexer share one body shape, {"error": {"code": "<code>", "message": "<text>"}}; the indexer's is inside its signed envelope. Clients branch on code, never on message.

Program errors

Custom errors of im-channels, as returned in a failed transaction (custom program error: 0x…). Codes are stable and only ever appended.

Code Hex Name Message
6000 0x1770 Arithmetic Checked arithmetic failed
6001 0x1771 Unauthorized Signer is not authorized for this operation
6002 0x1772 InvalidMint Vault mint must have six decimals
6003 0x1773 InvalidPayout Payout cannot be the vault token account
6004 0x1774 InvalidTime Invalid time or duration
6005 0x1775 TooManySellers Too many sellers in Mandate
6006 0x1776 InvalidAncestry Mandate account or ordered ancestor chain does not match
6007 0x1777 MandateExpired Mandate has expired or does not cover the service end time
6008 0x1778 MandateRevoked Mandate is revoked
6009 0x1779 MandateNotRevoked Neither the Mandate nor any ancestor is revoked or expired
6010 0x177a NotNarrowed Child Mandate would expand its parent's authority
6011 0x177b SellerNotAllowed Seller is not allowed by Mandate
6012 0x177c MandateBudget Mandate has insufficient unreserved period budget
6013 0x177d InsufficientFree Vault has insufficient free funds
6014 0x177e ChannelBudget Voucher total exceeds channel budget
6015 0x177f InvalidVoucher Voucher has the wrong length, tag, domain, channel, or epoch
6016 0x1780 MissingSignature The immediately preceding Ed25519 proof must contain one signature with local offsets and match the voucher and session key
6017 0x1781 DeadlinePassed Channel's redemption deadline has passed
6018 0x1782 DeadlineNotReached Channel's close deadline has not been reached
6019 0x1783 NotClosing Channel has not begun closing
6020 0x1784 AlreadyFinalized Channel is finalized
6021 0x1785 InvalidVersion Unsupported account version
6022 0x1786 InvalidTokenAccount Invalid classic SPL Token account, mint, state, or authority
6023 0x1787 InsolventVault Vault token balance cannot cover tracked liabilities
6024 0x1788 EpochNotIncreasing Channel epoch must be exactly the vault's last_channel_epoch + 1
6025 0x1789 MandateInUse Mandate still has live channels, reservations, or child Mandates
6026 0x178a NotOpen Channel is not open

<sub>Generated from programs/idl/im_channels.json, programs/programs/im-channels/src/lib.rs.</sub>

AlreadyFinalized is reserved: finalize closes the channel account, so a later instruction on it fails in Anchor's loader with AccountNotInitialized (3012) instead. Anchor's own constraint errors (for example ConstraintHasOne 2001, ConstraintSeeds 2006, InstructionDidNotDeserialize 102 for short instruction data) can also occur.

Gateway: Hold admission

Returned with HTTP 402 when a Hold is refused. The request is not billable.

error.code (HTTP 402) Message Retry the same request?
malformed_hold missing, malformed or misbound Hold no
bad_signature Hold is not signed by the channel session key no
unknown_channel channel is not in the local view no
channel_closed channel is not open for service no
wrong_seller channel settler or payout does not match the listing no
route_mismatch route is not listed here no
schedule_mismatch Hold does not match an effective price schedule no
hold_expired Hold dispatch deadline passed no
cap_exceeds_limit Hold cap exceeds the per-request limit no
cap_too_low Hold cap is below the route minimum no
insufficient_channel_funds channel has insufficient funds for this exposure yes, after a voucher ACK or a top-up
duplicate_request request id has already been admitted no
lane_replay lane counter must strictly increase no

<sub>Generated from services/gateway/src/gateway.ts.</sub>

Gateway: chat outcomes

Returned after a request was admitted. Each response carries the request's signed receipt in X-IM-Receipt, with the status shown.

HTTP error.code Message Receipt status
408 client_disconnected client disconnected cancelled or not_served
503 gateway_unavailable gateway stopped failed
504 backend_timeout backend timed out failed
400 invalid_request invalid chat request not_served
502, or the upstream 5xx status backend_failed backend failed failed
the upstream 4xx status (502 otherwise) backend_rejected backend declined request not_served

<sub>Generated from services/gateway/src/proxy.ts.</sub>

Gateway: other responses

HTTP error.code Message
503 gateway_unavailable gateway unavailable
503 gateway_draining gateway is draining
404 not_found receipt not found
404 not_found endpoint not found
413 invalid_request chat body exceeds limit
408 invalid_request chat body was not received
429 no_headroom route at capacity
503 ingress_busy too many pending uploads
503 gateway_unavailable could not persist receipt
502 backend_failed upstream usage cannot be billed

<sub>Generated from services/gateway/src/gateway.ts, services/gateway/src/proxy.ts.</sub>

gateway_draining, no_headroom and ingress_busy carry Retry-After: 1; the same Hold may be sent again. backend_failed with "upstream usage cannot be billed" is a non-streaming completion whose charge could not be computed; its receipt is failed with charge 0.

Gateway: voucher endpoint

Returned by POST /im/v1/vouchers.

HTTP error.code Message
400 (413 when the body exceeds 1 MiB) malformed_voucher invalid voucher body
400 bad_signature invalid voucher signature
400 wrong_channel voucher channel does not match
400 over_budget voucher total exceeds budget
400 channel_closed channel no longer accepts redemption
400 wrong_delta voucher total regressed
400 invalid_receipt receipt was not issued or is already acknowledged
400 receipt_order receipts must be unique and canonically ordered
400 wrong_delta voucher delta does not equal receipt charges
400 wrong_commitment voucher commitment does not match the receipts

<sub>Generated from services/gateway/src/vouchers.ts.</sub>

Discovery

HTTP error.code Message
400 invalid_filter Invalid route filters
400 invalid_observation Invalid observation
400 invalid_request Invalid request
403 forbidden_origin Origin not allowed
404 route_not_found Route not found
404 not_found Endpoint or method not found
405 method_not_allowed Method not allowed
409 observation_conflict Observation conflicts with an accepted window
413 request_too_large Request too large
503 response_too_large Response too large
503 service_unavailable Service unavailable

<sub>Generated from services/discovery/src/api.ts.</sub>

503 responses carry Retry-After: 1. response_too_large means the signed document would exceed 1 MiB; for a route page, even with a single route.

Protocol libraries

ProtocolError.code in @im/protocol and im_protocol::Error in Rust use the same names.

ErrorCode / Rust Error Meaning
Length wrong message length
Tag wrong message type tag
TapeConsent tape consent must be 0 in the MVP
Status unknown receipt status
UsageSource unknown usage source
ChargeAboveCap receipt charge exceeds cap
RouteIdentity route identity requires seller_id, endpoint, model_identity_id and a 32-byte lowercase hex nonce
DuplicateReceipt duplicate receipt ordering key
ChargeOverflow charge does not fit in u64
JsonNumber JSON numbers must be integers in [0, 2^53 - 1]
JsonSyntax invalid JSON
WireInteger wire integer out of range
DomainMismatch message does not belong to the expected domain
KeyLength wrong Ed25519 key length
SignatureLength wrong Ed25519 signature length
BadSignature signature does not match the expected signer
JsonDuplicateKey duplicate JSON object key
JsonDepth JSON exceeds maximum container depth
JsonSize JSON exceeds maximum UTF-8 byte length

<sub>Generated from packages/protocol/src/errors.ts, crates/im-protocol/src/lib.rs.</sub>