Developer Reference

API v1 and MCP Protocol Reference

OpenAI-compatible REST routes and Model Context Protocol transport for programmatic access to your infrastructure.

01

Base URL

Route every request to the production backend host below.

text
https://cexi.my.id
01a

Security: Handling API Keys & Secrets

Never Commit API Keys to Version Control

API keys are SECRET credentials. Exposed keys can consume your token quota or grant unauthorized infrastructure access.

text
[INSECURE] const apiKey = "mf_live_xyz";
[INSECURE] API_KEY=mf_live_xyz in git-committed .env file
[INSECURE] Sharing keys in Slack, Discord, chat logs
.env (recommended)
export API_KEY="mf_live_your_actual_key_here"
# In code: process.env.API_KEY || process.env.MAF_API_KEY

# Add .gitignore:
.env*
*.env

Production: Use secret management services

HashiCorp Vault, AWS Secrets Manager, or similar. Inject at runtime; never commit.

If you accidentally expose a key:

  1. Revoke immediately in dashboard, then the API Keys tab
  2. Create a new API key with limited scope
  3. Check usage logs for unauthorized activity
02

Authentication

Include credentials in the Authorization header using the Bearer scheme.

http
Authorization: Bearer mf_live_xxx   # API Key (PRO or STUDIO plan)
Authorization: Bearer <jwt-token>    # Session Token

Rate Limits & Quotas

PRO plans receive higher quotas. On limits exceeded, you'll receive a 429 Too Many Requests response. Implement exponential backoff.

03

REST API v1

OpenAI-compatible routes. The completions endpoint accepts standard SDK request shapes.

GET /v1/modelshttps://cexi.my.id/v1/models

Returns available model catalog: claude-opus-4-7 (primary), qwen-3.8-max (fallback).

bash
curl -X GET https://cexi.my.id/v1/models -H "Authorization: Bearer mf_live_xxx"
POST /v1/chat/completionshttps://cexi.my.id/v1/chat/completions

Chat completion. Supports streaming, tool calling, effort-based reasoning.

bash
curl -X POST https://cexi.my.id/v1/chat/completions \
  -H "Authorization: Bearer mf_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-opus-4-7","messages":[{"role":"user","content":"Hello!"}],"stream":false}'
04

Available Models

All requests route to the primary M.A.F Cloud AI gateway unless a custom backend is configured.

Primary: claude-opus-4-7

Flagship model for complex reasoning and diagnostics.

Fallback: qwen-3.8-max

Advanced bilingual model. Auto-failover when Claude is unavailable.

Custom Models via Environment

bash
AI_MODELS=custom-model-1,claude-opus-4-7,qwen-3.8-max

First model in list becomes the primary fallback.

05

SDK Examples

Idiomatic patterns for all major languages. Copy-paste ready with error handling.

import axios from "axios";
 
const API_KEY = process.env.API_KEY || "mf_live_xxx";
 
try {
const response = await axios.post(
"https://cexi.my.id/v1/chat/completions",
{
model: "claude-opus-4-7",
messages: [{ role: "user", content: "Hello!" }],
stream: false,
effort: "high"
},
{
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
}
}
);
 
console.log(response.data.choices[0].message.content);
} catch (error) {
console.error("Request failed:", error);
}

Required Environment Variables

  • NODE_ENV=production
  • API_KEY=mf_live_xxx
  • export API_KEY=mf_live_xxx
  • export BASE_URL=https://cexi.my.id

Dependencies

  • TypeScript: npm install axios
  • Python: pip install openai
  • Go: go get github.com/google/go-querystring/query
  • Rust: cargo add reqwest tokio serde serde_json
06

Testing Guide

Comprehensive workflows for local development and production validation.

Quick Start Tests

Run these cURL commands to verify environment:

health-check
# Health check endpoint
curl -fsSL https://cexi.my.id/health

Rate Limit Monitoring

Monitor performance and understand rate limiting:

rate-limit-watch
# Rate limit check
watch -n 10 'curl -fsSLI -H "Authorization: Bearer YOUR_API_KEY" https://cexi.my.id/health'
07

Error Handling

Error responses follow RFC 7807 format. Always implement exponential backoff for 429 status codes.

StatusNameDescriptionAction
400Bad RequestInvalid payload or malformed parametersFix input first
401UnauthorizedMissing or invalid Authorization headerRefresh token or key
429Too Many RequestsRate limit exceededExponential backoff
502Bad GatewayUpstream service unavailableTemporary
08

Model Context Protocol

Connect Claude Desktop, Cursor, or any MCP-compatible client to drive nodes and servers programmatically.

GET /mcp/infohttps://cexi.my.id/mcp/info

Server metadata: name, version, protocol version, capabilities.

GET /mcp/toolshttps://cexi.my.id/mcp/tools

Enumerates tools including list_nodes, control_server, rcon_command, deploy_from_git.

bash
curl -X GET https://cexi.my.id/mcp/tools -H "Authorization: Bearer your_jwt_token"
POST /mcp/tools/callhttps://cexi.my.id/mcp/tools/call

Invoke a named tool with arguments. Call rcon_command, create_subdomain, delete_server, and so on.

bash
curl -X POST https://cexi.my.id/mcp/tools/call -H "Authorization: Bearer your_jwt_token" -H "Content-Type: application/json" -d '{"name":"rcon_command","arguments":{"serverId":"server_id"}}'