Developer Reference
API v1 and MCP Protocol Reference
OpenAI-compatible REST routes and Model Context Protocol transport for programmatic access to your infrastructure.
Base URL
Route every request to the production backend host below.
https://cexi.my.idSecurity: 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.
[INSECURE] const apiKey = "mf_live_xyz";
[INSECURE] API_KEY=mf_live_xyz in git-committed .env file
[INSECURE] Sharing keys in Slack, Discord, chat logsexport API_KEY="mf_live_your_actual_key_here"
# In code: process.env.API_KEY || process.env.MAF_API_KEY
# Add .gitignore:
.env*
*.envProduction: Use secret management services
HashiCorp Vault, AWS Secrets Manager, or similar. Inject at runtime; never commit.
If you accidentally expose a key:
- Revoke immediately in dashboard, then the API Keys tab
- Create a new API key with limited scope
- Check usage logs for unauthorized activity
Authentication
Include credentials in the Authorization header using the Bearer scheme.
Authorization: Bearer mf_live_xxx # API Key (PRO or STUDIO plan)
Authorization: Bearer <jwt-token> # Session TokenRate Limits & Quotas
PRO plans receive higher quotas. On limits exceeded, you'll receive a 429 Too Many Requests response. Implement exponential backoff.
REST API v1
OpenAI-compatible routes. The completions endpoint accepts standard SDK request shapes.
Returns available model catalog: claude-opus-4-7 (primary), qwen-3.8-max (fallback).
curl -X GET https://cexi.my.id/v1/models -H "Authorization: Bearer mf_live_xxx"Chat completion. Supports streaming, tool calling, effort-based reasoning.
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}'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
AI_MODELS=custom-model-1,claude-opus-4-7,qwen-3.8-maxFirst model in list becomes the primary fallback.
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
Testing Guide
Comprehensive workflows for local development and production validation.
Quick Start Tests
Run these cURL commands to verify environment:
# Health check endpoint
curl -fsSL https://cexi.my.id/healthRate Limit Monitoring
Monitor performance and understand rate limiting:
# Rate limit check
watch -n 10 'curl -fsSLI -H "Authorization: Bearer YOUR_API_KEY" https://cexi.my.id/health'Error Handling
Error responses follow RFC 7807 format. Always implement exponential backoff for 429 status codes.
| Status | Name | Description | Action |
|---|---|---|---|
| 400 | Bad Request | Invalid payload or malformed parameters | Fix input first |
| 401 | Unauthorized | Missing or invalid Authorization header | Refresh token or key |
| 429 | Too Many Requests | Rate limit exceeded | Exponential backoff |
| 502 | Bad Gateway | Upstream service unavailable | Temporary |
Model Context Protocol
Connect Claude Desktop, Cursor, or any MCP-compatible client to drive nodes and servers programmatically.
Server metadata: name, version, protocol version, capabilities.
Enumerates tools including list_nodes, control_server, rcon_command, deploy_from_git.
curl -X GET https://cexi.my.id/mcp/tools -H "Authorization: Bearer your_jwt_token"Invoke a named tool with arguments. Call rcon_command, create_subdomain, delete_server, and so on.
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"}}'