Skip to content
Docs Inference platform

PLATFORM / API compatibility

API compatibility

Endpoint directory, authentication, headers, streaming, and errors.

Integration guide · planned capabilities

Model-specific capabilities, usage rates, and x402 upto settlement require backend implementation and validation. The preview runs local samples; documented contracts do not imply live availability.

Implementation target. This guide specifies the intended product surface. The current frontend uses local samples; it does not call an inference service or collect funds. An endpoint is enabled only after its adapter, ownership, usage, and payment behavior are qualified.

Planned API origin. Examples use https://noemad.dev/v1, the intended product API path. The API is not connected in this frontend preview. MODEL_ID_FROM_DISCOVERY and NOEMAD_API_KEY are placeholders, not published credentials or model IDs. A product API key identifies an account; a separate payment-aware transport must handle spending authorization.

Two related API surfaces

/v1 retains the inference request and response families. Wallet authentication and payment status are additional product endpoints. They do not replace Chat Completions, Responses, Messages, or specialized modality payloads with a single text-only wrapper.

MethodPathPurpose
POST/v1/chat/completionsChat Completions JSON / SSE; messages and tools
POST/v1/responsesResponses JSON / event stream
POST/v1/messagesMessages content blocks / event stream
POST/v1/messages/count_tokensCompatible token count; qualification required
POST/v1/images/generationsImage generation
POST/v1/images/editsImage editing with a validated source
POST/v1/videosCreate a durable video job
GET/v1/videos/{id}Read job state and result
POST/v1/audio/speechSpeech synthesis
POST/v1/audio/transcriptionsAudio transcription
POST/v1/filesOwner-scoped upload
GET/v1/artifacts/download/{token}Expiring owner-scoped artifact delivery
POST/v1/realtime/callsNegotiate one WebRTC voice session
DELETE/v1/realtime/sessions/{id}Release a session
POST/v1/embeddingsCreate indexed text vectors
POST/v1/rerankRank supplied candidate documents
POST/v1/structured-evaluationTyped answers from state and questions; renamed product route
GET/v1/modelsCaller-scoped model discovery
GET/v1/usageThe product owner’s usage; no shared provider balance
GET/calculate/modelsQuoteable rate specifications
GET/calculateQuote a bounded request shape
POST/dashboard/wallet/challengeCreate a wallet sign-in challenge
POST/dashboard/wallet/verifyVerify a signed challenge
GET/api/v1/payments/{quote_id}Owner-only inference and collection state, actual cost, receipt

The structured-evaluation route is an explicit product naming change. The precise DTOs and headers remain implementation contracts to freeze with backend fixtures before enabling clients.

Product identity and payment are separate

Inference uses a scoped Noemad product API key or a supported playground session. The key belongs to the wallet account. It can restrict models, expiry, rate, and concurrency; it is not a provider key and does not authorize a token debit.

HTTP headers
Authorization: Bearer NOEMAD_API_KEY
Content-Type: application/json

# Messages-compatible authentication, if supported by the frozen contract:
x-api-key: NOEMAD_API_KEY

The intended wallet entry uses /dashboard/wallet/challenge and /dashboard/wallet/verify. Connection is followed by a server-verified challenge; the session must enforce origin, nonce, expiry, cookie security, and CSRF protection.

Common and payment headers

HeaderUse
Authorization / x-api-keyProduct authentication, according to the endpoint contract
Content-TypeMatch JSON, multipart, SDP, or binary endpoint requirements
Idempotency-KeyOne key for one immutable logical mutation
X-Request-IDA bounded caller correlation value; not proof of deduplication
PAYMENT-REQUIREDx402 payment requirements returned with HTTP 402
PAYMENT-SIGNATUREClient authorization using the pinned x402 v2 upto schema
X-Quote-IDProduct extension binding retry to the immutable quote
Retry-AfterDelay before another eligible status check or safe retry
X-Noemad-Request-IDProposed product correlation header; final spelling requires fixture agreement
X-Noemad-Realtime-Control-TokenProposed session-release token header; keep it out of logs and URLs

Generic SDKs do not automatically understand the quote extension. Use a payment-aware transport or local proxy owned by the user. Do not invent a payment signature format or silently sign on a user’s behalf.

402 → authorize maximum → deliver → settle actual

  1. Authenticate and validate the exact model, body, route, rate, and admission limits.
  2. Create a quote and return payment requirements before inference.
  3. The client checks the quote and obtains a bounded wallet authorization.
  4. Retry the same operation with the same quote, body, and authorization.
  5. The server binds the nonce once, then streams or returns the inference result.
  6. After reliable usage is final, calculate and collect the actual amount within the maximum.
  7. Read GET /api/v1/payments/{quote_id} for collection state and the verified receipt.

The unused maximum remains in the wallet. Authorization does not transfer the maximum, reserve the wallet balance, or prove future collection will succeed.

Inspect the full response lifecycle

An error before response headers can use an HTTP error status. After a response begins, an error may arrive within an HTTP 200 stream. A buffered response can also contain an error body after initial whitespace. Always inspect the terminal payload.

ProtocolTerminal failure reference
Chat Completions SSEAn error object in a data frame; do not assume partial choices completed
Messages SSEAn error event with the Messages error envelope
Responses SSEresponse.failed with response.error fields
Buffered JSONA complete parsed result or an error envelope
Payment collectionA separate owner-only status after inference; never inferred from stream success

Do not insert product payment events into an established SSE protocol without an explicit compatibility design. A final settlement header cannot be added to already-sent HTTP headers. Partial tool arguments must never be executed.

Error directory

These codes retain the reference surface where applicable; the wallet/payment extension replaces prepaid-credit errors with explicit quote and collection states. Final mappings require endpoint fixtures. Check the machine-readable code and owner-scoped status instead of inferring a cause from a generic message.

HTTPCodeAction
400invalid_client_request_idCorrect the caller request ID.
400invalid_fileValidate file bytes, encoding, size, and accepted type.
400invalid_imageValidate image bytes, dimensions, and encoding.
400invalid_reasoning_effortUse a level advertised by the selected model.
400invalid_request_errorCorrect missing fields, invalid JSON, or invalid parameter values.
400invalid_tool_historyMatch each tool result to its original tool-call ID.
400output_token_limit_exceededLower the output cap before a new quote.
400request_blocked_by_policyReview the request; repeated retries do not change a policy decision.
400streaming_requiredUse a supported streaming transport with the same product payment rules.
400unsupported_model_for_endpointChoose a model qualified for this endpoint.
400unsupported_request_parameterRemove or correct the unsupported control.
400unsupported_toolsUse a supported tool declaration or model.
401invalid_api_keyCheck the product key; never substitute a provider credential.
402payment_requiredReview the quote and authorization; a bearer key does not authorize spending.
403key_expired / key_revokedRenew or replace the product key through the owner session.
403permission_deniedCheck account role, model scope, and ownership.
403entitlement_limitRespect the active per-request offer or account limit.
404model_not_foundRefresh authenticated model discovery.
413request_too_largeReduce the conversation or attachment size.
422unsupported_input_modalityChoose a compatible model and payload.
429client_error_cooldownWait and correct repeated invalid requests.
429concurrency_limitWait for an active operation to finish.
429image_requests_temporarily_limitedHonor the delay before another image operation.
429ip_rate_limitReduce request frequency from the network.
429model_rate_limitedWait before another request to that model.
429rate_limitHonor Retry-After and the account or key limit.
500internal_errorUse bounded backoff; preserve the quote and operation reference.
500token_count_failedRecord the request ID and retry only when safe.
502empty_model_responseNo usable output was returned; inspect the operation outcome.
502invalid_model_responseDo not treat an unparsable response as success.
502invalid_model_tool_argumentsNever execute incomplete or invalid tool arguments.
502invalid_model_tool_callNever execute an undeclared tool.
502request_processing_failedInspect owner-scoped operation state before another dispatch.
502stream_interruptedPartial text or tool arguments remain incomplete.
502tool_generation_limit_exceededDo not execute the incomplete action.
503model_temporarily_unavailableUse bounded backoff; the code alone does not identify a cause.
503service_busyHonor Retry-After and avoid duplicate operations.
504generation_timeoutReconcile a possibly dispatched operation before creating another.
504stream_idle_timeoutInspect the terminal outcome and any completed tool actions.
504stream_time_limit_exceededTreat partial output according to the published delivery policy.
504token_count_timeoutUse bounded backoff and retain correlation metadata.

Retry and support information

Correct input, identity, permission, scope, and policy failures before retrying. For transient failures, use bounded exponential backoff with jitter and honor a numeric Retry-After. Preserve quote, operation, and idempotency identity; do not create a second paid operation because the first timed out.

Save the product request ID, endpoint, model, approximate time, and operation reference. Exclude credentials, raw payment signatures, and private session-control tokens from support messages and public logs.

Ownership and asynchronous resources

Files, jobs, sessions, results, and artifact grants belong to the authenticated product owner. Video uses a durable submit/poll lifecycle. Realtime uses one session across turns and requires explicit release. An expiring artifact URL is a delivery mechanism rather than permanent hosting.