REFERENCE

Client API reference

Build against the supported client-management endpoints. Authentication binds every operation to your business; a URL or body field never grants a broader scope.

Download OpenAPI 3.1 Agent & API Reference (llms-full.txt)

The downloadable OpenAPI contract covers client management only. For project-key inference, streaming and receipts, use Your first call; for MCP agent hosts, see Use Modelvia from an agent host; or give coding agents /llms-full.txt for the single-file inference, client and MCP reference. Member sessions, identity bridges and internal operator controls are outside this API.

Authentication and prerequisites

Base URL: https://api.modelvia.dev. Send Authorization: Bearer $MODELVIA_CLIENT_KEY with the dedicated mgt_ integration key from operator-assisted onboarding. This is a backend management credential. Keep it out of browser JavaScript, mobile bundles, shared logs and customer-visible responses.

Your active client account defines the owning business, payer, allowed models and ceilings. Establish billing identity, accepted rates, service entitlement and customer commercial policies with Modelvia before serving real usage. Creating records does not activate terms. Start with Customers, projects and keys for the complete sequence.

JSON requests use Content-Type: application/json. Successful operations return HTTP 200, including creates. Refusals return {"error":"code"}. The invoice document route returns HTML. No client-key request requires or accepts an operator secret.

Supported operations

Replace path parameters with the exact IDs you retain on your server. Customer/project path IDs use letters, numbers, underscores, periods or hyphens; prefer a business prefix. Key IDs are 16 lowercase hexadecimal characters.

Every route below uses your client integration key.
OperationEndpoint
List customersGET /v1/client/customers

Returns only customers of the authenticated client.

Create customerPOST /v1/client/customers

Requires pre-arranged client billing ownership. No version/billingCompanyId accepted. Prefix your IDs. Caps/concurrency/models narrow the client.

Create projectPOST /v1/client/customers/{customer}/projects

Requires your own customer with your client as payer. Customer-paid billing needs operator assistance. Child narrows parent; request cap cannot exceed monthly cap.

List project keysGET /v1/client/customers/{customer}/projects/{project}/keys

Metadata only, never secrets. Includes revoked/expired keys; check timestamps and environment.

Mint project keyPOST /v1/client/customers/{customer}/projects/{project}/keys

Active ancestry, permitted environment and active unexpired client-paid billing service required. At most 100 active keys per client. Secret shown once. Serialize key issuance; list/reconcile after an unknown result.

Rotate project keyPOST /v1/client/customers/{customer}/projects/{project}/keys/{key}/rotate

No request fields. Issues a new secret and revokes the old key. After an unknown result, list and reconcile before another mutation.

Revoke project keyPOST /v1/client/customers/{customer}/projects/{project}/keys/{key}/revoke

No request fields. Only this scoped project key. Repeating preserves revokedAt.

Read customer usageGET /v1/client/customers/{customer}/usage-summary

Customer-safe totals independent of invoices. Null means unknown. Sums the whole month at any volume; there is no request count that refuses the read. Retain request binding: response has no customerId.

Read customer billingGET /v1/client/customers/{customer}/billing

Check response clientId/customerId against your authenticated server binding. Estimates are not final invoices. Render payment actions only from authoritative flags.

Read resale invoiceGET /v1/client/customers/{customer}/invoices/{invoice}

Issued client resale invoice plus payment state. Platform-billed invoices use a separate portal contract, not this resale-document route.

Read resale invoice documentGET /v1/client/customers/{customer}/invoices/{invoice}/document

Issued scoped resale invoice as HTML; display in a sandboxed document surface.

Start invoice checkoutPOST /v1/client/customers/{customer}/invoices/{invoice}/checkout

No request fields. Authoritative invoice selects amount and seller. Read checkoutAvailable first. Resale uses seller Square merchant; platform payer branch uses separate hosted collection. Unknown outcome holds all payment actions across reload; not_started alone cannot release it.

Record received direct paymentPOST /v1/client/customers/{customer}/invoices/{invoice}/external-payment

Provider bookkeeping; moves no money. Exact full positive issued resale invoice only, direct method permitted, no Square link or credit adjustment. No partial payment, customer self-report or manual refund.

Read payment methodsGET /v1/client/payment-settings

Methods differ from checkout surface. Square configured does not mean live money movement.

Set payment methodsPOST /v1/client/payment-settings

clientId asserts authenticated provider, never selects scope. Current version required. Read back after conflict/unknown result before retry. Trusted server credential, not a member-session MFA contract.

Read what customers are shown of each chargeGET /v1/client/charge-detail

all_in (default) shows end customers one AI usage amount; itemized splits the same amount into model usage, routing and service fee. You always see the full breakdown on your own Modelvia invoices.

Set what customers are shown of each chargePOST /v1/client/charge-detail

clientId asserts the authenticated client, never selects scope. Current version required; 409 account_version_conflict or charge_detail_scope_changed means read back before retrying. Presentation only: no price, total or issued invoice changes.

Provisioning request bodies

The JSON examples on the customer setup guide come from this same OpenAPI contract. All caps are exact integer strings in nano-AUD; 1 AUD is 1,000,000,000 nano-AUD. They must fit your agreed parent account.

Fields accepted by customer and project creation.
BodyFields and restrictions
Customerid, name, active, monthlyCapNanoAud, maxConcurrent, allowedModels required. Optional clientId only asserts the key’s own client. payer: "client" is only for mixed billing; otherwise omit it.
ProjectThe same six required fields plus environments and requestCapNanoAud. Optional clientId/customerId must match existing authenticated ancestry.
Key mintenvironment required; label optional. No custom billing binding or expiry field on this endpoint.
Server-managedDo not send version on creates or billingCompanyId on either body. Billing ownership and commercial acceptance are assisted operations.

Key lifecycle and retries

Mint/rotate responses contain key and public record; rotation additionally returns replaced, the previous key ID. The secret is shown once. Listing returns {"keys":[...]} without secret/hash fields.

Do not automatically replay key issuance. Repeating a mint POST issues another secret. A successful rotation revokes the original key; repeating that original rotation URL returns key_revoked (409), without recovering the replacement secret. An Idempotency-Key header does not provide response replay for either operation. Serialize issuance and list/reconcile keys after an unknown response before deliberately replacing a credential. Revocation preserves the original revokedAt on repeated calls.

Revoke one named project key
# KEY_ID is the 16-character id from the key record, not the secret.
# Choose ONE operation deliberately. Do not run these as a sequence.
# Rotate: POST .../keys/$KEY_ID/rotate (returns a new one-time secret)
# Revoke: POST .../keys/$KEY_ID/revoke (returns the revoked public record)
curl --fail-with-body -X POST \
  "$MODELVIA_API_URL/v1/client/customers/$MODELVIA_CUSTOMER_ID/projects/$MODELVIA_PROJECT_ID/keys/$KEY_ID/revoke" \
  -H "Authorization: Bearer $MODELVIA_CLIENT_KEY"

Customer/project creates behave differently: an identical body returns the existing record without another write; a changed body returns 409 account_version_conflict. Inference has its own stable request-idempotency rules.

Read one customer’s month

Set MODELVIA_PERIOD to YYYY-MM, or omit the query for the current month in Australia/Brisbane. Usage-summary accepts only one period and no other filters.

Customer usage summary
curl --fail-with-body \
  "$MODELVIA_API_URL/v1/client/customers/$MODELVIA_CUSTOMER_ID/usage-summary?period=$MODELVIA_PERIOD" \
  -H "Authorization: Bearer $MODELVIA_CLIENT_KEY"

Illustrative empty connected month
{
  "period": "2026-09",
  "requests": 0,
  "tokens": {
    "input": "0",
    "output": "0"
  },
  "money": {
    "customerNetNanoAud": "0"
  },
  "monthlyCapNanoAud": "50000000000",
  "remainingNanoAud": "50000000000",
  "updatedAt": 1790200000000
}

This example is a valid empty month after a successful scoped read. A failed connection is unavailable, not zero. Monetary totals can be null; input tokens exclude cache reads/writes; remainingNanoAud is display headroom, not a promise of admission. updatedAt is epoch milliseconds.

Summary has no customer ID field: retain and check your own request context. Billing includes clientId and customerId; verify them before rendering. Usage totals sum the whole month at any volume; only the recent-requests list is paged, with requestsLimit (1–500) and requestsCursor from the previous recentRequestsPage.nextCursor. Never present a partial page as a complete period.

Build the customer console covers identity, display and privacy. Business-level analytics are not a customer-safe response and are intentionally outside this focused contract.

Invoices and payment methods

A usage estimate is not an issued invoice. The invoice names its seller; Square checkout does not change that owner. Method settings use the current clientId assertion and version. Customer payment actions also depend on the separate checkout surface and fresh server eligibility.

Checkout takes no amount or seller body. Direct-payment recording is provider bookkeeping for an exact full amount already received; it never charges the customer. An unresolved checkout must suppress all collection alternatives across reload, even if a fresh read says not_started. See payments and recovery before enabling either route.

The OpenAPI billing/invoice response schemas describe the verified fields. Tolerate additional response fields, but render or forward only the documented fields needed for your customer’s view. Never infer eligibility from a missing property.

Errors and recovery

Act on status and code, with the operation’s retry semantics.
StatusAction
400Correct invalid fields, money, models, environments or parent limits. A project cannot widen its customer.
401 / 403Resolve an invalid/revoked client key, inactive account or billing authority. Never substitute another tenant’s ID.
404Scoped resource is missing or unavailable to this key. Foreign resources are not disclosed.
409Inspect the code: account conflict, unavailable ID, changed payment-settings scope/version or reconciliation required. Read back before retrying a settings/payment mutation.
413 / 429Respect the bounded-read limit. For 429, honour Retry-After and reduce concurrency; do not indiscriminately replay mutations.
Timeout / 5xxThe result may be unknown. Preserve the original request, account binding and operation state; apply the specific create, key or payment recovery rule.