API Reference

Quick start

Find a model, issue a virtual-key token, send a chat completion, create a department, and review the audit log.

Quick start

This walkthrough covers the most common calls: find a model, issue a virtual-key token, send a chat completion through the AI gateway, create a department, assign a member, and review activity. Replace the uppercase placeholders with your own values.

See Overview for authentication, pagination, and error codes.

Set your base URLs and token

Use your Monetize360 tenant host, your AI gateway URL, and the tenant Bearer token (the JWT from signing in).

export BASE="https://YOUR_TENANT_HOST/api/v1"
export GATEWAY="https://YOUR_GATEWAY_URL"
export TOKEN="YOUR_API_TOKEN"

List models

curl -H "Authorization: Bearer $TOKEN" \
  "$BASE/model-catalog?page=0&size=5&sortBy=popularity"

The id on each row is the catalog listing id. You use it to fetch one model. See Models.

Get one model

curl -H "Authorization: Bearer $TOKEN" \
  "$BASE/model-catalog/LISTING_ID"

The response includes the listing and its rate card (matrixRates).

Issue a virtual-key token

export VK_TOKEN=$(curl -s -X POST -H "Authorization: Bearer $TOKEN" \
  "$BASE/virtual-key-tokens/generate?virtualKeyId=VIRTUAL_KEY_ID")

The response body is the raw JWT text, not JSON, so it is saved straight into $VK_TOKEN. Applications send this token to the AI gateway. It is a different credential from $TOKEN, which only calls these management APIs. See Keys.

Send a chat completion

Call the AI gateway with the virtual-key token from the previous step. Use a model in provider/model form; the catalog rows from the list call show which models are available.

curl -s -X POST "$GATEWAY/v1/chat/completions" \
  -H "Authorization: Bearer $VK_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [
      {"role": "user", "content": "Hello"}
    ],
    "max_completion_tokens": 256
  }'

The reply text is in choices[0].message.content, and usage shows the tokens used and their cost. See Chat completions for streaming and all request fields.

Create a department

curl -X POST -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "$BASE/mdata/mobject/b7c4a1e2-903f-4b2d-8c61-0a1b2c3d4e5f" \
  -d '{
    "data": {
      "code": "ENG",
      "name": "Engineering",
      "org_unit_type": "e1f8d5c4-4362-8f70-9a01-5b6c7d8e9f02"
    }
  }'

The response id is the new department's id. Use it as orgUnitId in the next step. See Departments.

Assign a member to the department

This call needs a member-manager role (ORG_ADMIN, SUPERADMIN, TENANTADMIN, or ROLE_SYSTEM). Use GET /users to find the member's id and the role id.

curl -X PUT -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "$BASE/users/standard-component/USER_ID" \
  -d '{
    "roleId": "ROLE_ID",
    "orgUnitId": "DEPARTMENT_ID"
  }'

See Members.

Review the audit log

curl -X POST -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "$BASE/audit-log?page=0&size=20" \
  -d '{
    "objectName": "OrgUnit",
    "auditInterval": "LAST_7_DAYS"
  }'

You should see the department you created. See Audit log.

If a call fails, check the status codes under Errors. A 401 means a missing or invalid tenant token, and a 403 means the token lacks a member-manager role. For the chat completion, see Error response: a 401 there means a missing or revoked virtual key, and a 402 means a budget was exceeded.