The Cosmo API lets you integrate Luau obfuscation directly into your workflow. Protect your Roblox scripts programmatically with industry-leading VM and Shell obfuscation — from your own backend, CI/CD pipeline, or any HTTP client.
Quick Start
1
Create an account
Sign up at cosmo-rblx.online if you haven't already. You need an active plan to use the API.
2
Generate an API key
Navigate to Dashboard → Settings → API Keys and create a new key. Copy it immediately — it won't be shown again.
3
Make your first request
Use the example below to obfuscate a script with VM mode.
All API requests must include your API key in the Authorization header using the Bearer token scheme. Every request without a valid key will receive a 401 Unauthorized response.
Authorization: Bearer cosmo_sk_xxxxxxxxxxxxxxxx
API keys follow the format cosmo_sk_ followed by a 16-character alphanumeric string. Keys are tied to your account and inherit your plan's rate limits and quotas.
Never expose your API key in client-side code. Always route requests through your own backend server. If a key is compromised, rotate it immediately from your dashboard.
API keys are managed from your Cosmo dashboard. Each key provides full access to the obfuscation endpoints within your plan's limits.
Generating a Key
1
Open your Dashboard
Log in and navigate to your account dashboard.
2
Go to Settings → API Keys
Find the API Keys section in your account settings.
3
Create New Key
Click Generate New Key. Give it a descriptive label (e.g., "Production Backend" or "CI Pipeline").
4
Copy and store securely
The full key is shown only once. Store it in your environment variables or secrets manager.
Key Permissions
All keys currently have full access to your account's API capabilities. Scoped permissions (read-only, specific endpoints) are on the roadmap. For now, treat every key as having full access and restrict distribution accordingly.
Rotating Keys
If a key is compromised or you want to rotate for security hygiene, generate a new key first, update all your services, then revoke the old key from the dashboard. This avoids downtime during rotation.
Use environment variables (COSMO_API_KEY) in all environments. Never commit keys to version control. Consider using a secrets manager like Vault, AWS Secrets Manager, or GitHub Encrypted Secrets for production deployments.
Protect User Scripts
Build a platform where users submit their Luau scripts for protection — without ever seeing the obfuscated output. Your backend handles obfuscation transparently, stores the protected code, and serves it when needed.
This is the recommended pattern for script marketplaces, loader platforms, and any service where end users should not have access to the raw obfuscated code. The API key stays on your server, and users never interact with Cosmo directly.
How It Works
User submits script
Your backend
Cosmo API
Store protected code
1
User uploads their Luau script on your platform
They paste or upload source code through your website UI.
2
Your backend sends it to Cosmo API
You choose the mode (vm or shell) and always enable macros. The user never sees these options unless you want them to.
3
Cosmo returns the obfuscated code
Your backend receives the protected output. The user never sees it.
4
Store and serve the protected version
Save the obfuscated code in your database. Serve it to Roblox loaders, key systems, or wherever needed.
Backend Implementation
The developer pre-configures the obfuscation mode and enables macros. Users only submit their source code — everything else is handled server-side.
Never expose your API key in frontend code. Always proxy requests through your backend. If a key is compromised, rotate it immediately from the Cosmo dashboard.
For high-volume platforms, consider caching obfuscated output and only re-obfuscating when the source code changes. Compare hashes of the source to avoid unnecessary API calls and save on your plan limits.
Live Demo
Try Cosmo obfuscation right here — no API key needed. This demo uses a server-side protected endpoint with the same obfuscation engine used in production. The obfuscated output is never returned to the browser, just like in a real backend-to-backend integration.
Macros: always enabled
Loading editor...
131 / 2000 characters
This demo is limited to 2000 characters. For unlimited obfuscation, full API access, and production-ready integrations, check out our Pro and Cosmic plans.
VM Obfuscation
VM mode provides the strongest level of protection available. Your Luau source code is compiled into custom bytecode that runs inside Cosmo's proprietary virtual machine. This makes reverse engineering extremely difficult, as the original logic is never present in the output.
POST/api/obfuscate
Parameter
Type
Required
Description
source
string
Yes
The Luau source code to obfuscate
mode
string
No
"vm" (default) — Virtual machine obfuscation
filename
string
No
File name for error reporting (default: "script.lua")
Shell mode wraps your code in multiple layers of encrypted shells. While not as deeply protective as VM mode, Shell obfuscation is significantly faster and produces more compact output — making it ideal for scripts that update frequently or where runtime performance is critical.
POST/api/obfuscate
Parameter
Type
Required
Description
source
string
Yes
The Luau source code to obfuscate
mode
string
Yes
"shell" — Shell-based obfuscation
filename
string
No
File name for error reporting (default: "script.lua")
Retrieve your current usage statistics, plan details, and subscription status. Use this endpoint to monitor your quota before making obfuscation requests or to display usage information in your application.
Test Cosmo API endpoints directly from the documentation. Enter your API key, select an endpoint, configure your request, and send it live.
Request Builder
Loading editor...
Response
Send a request to see the response
Add to Your Website
Integrate Cosmo obfuscation into your web application by proxying requests through your backend. This keeps your API key secure and gives you full control over access.
Always call the Cosmo API from your backend server, never from the browser. CORS restrictions and API key security both require a server-side proxy approach.
You can call the Cosmo API directly from Roblox game servers using HttpService. This is useful for on-demand obfuscation, dynamic script loaders, or building key systems.
Make sure to enable Allow HTTP Requests in your game's settings (Game Settings → Security). API keys stored in Roblox scripts should be kept server-side only — never distribute them in client-facing code.
Basic HttpService Request
local HttpService = game:GetService("HttpService")
local API_KEY = "cosmo_sk_xxxxxxxxxxxxxxxx"
local function obfuscate(source, mode)
mode = mode or "vm"
local success, result = pcall(function()
return HttpService:RequestAsync({
Url = "https://www.cosmo-rblx.online/api/obfuscate",
Method = "POST",
Headers = {
["Authorization"] = "Bearer " .. API_KEY,
["Content-Type"] = "application/json",
},
Body = HttpService:JSONEncode({
source = source,
mode = mode,
}),
})
end)
if success and result.Success then
local data = HttpService:JSONDecode(result.Body)
return data.obfuscated
else
warn("Obfuscation failed:", result)
return nil
end
end
local protected = obfuscate([[
print("This script is now protected!")
]], "vm")
if protected then
print("Obfuscation successful! Length:", #protected)
end
Key System Example
Build a key-based distribution system where scripts are obfuscated on-demand and served to authorized users.
local HttpService = game:GetService("HttpService")
local DataStoreService = game:GetService("DataStoreService")
local keyStore = DataStoreService:GetDataStore("LicenseKeys")
local API_KEY = "cosmo_sk_xxxxxxxxxxxxxxxx"
local SCRIPT_SOURCE = [[
local player = game.Players.LocalPlayer
-- Your protected script logic here
print("Licensed to: " .. player.Name)
]]
local function validateAndServe(player, licenseKey)
local success, keyData = pcall(function()
return keyStore:GetAsync(licenseKey)
end)
if not success or not keyData then
return { success = false, error = "Invalid license key" }
end
if keyData.expiresAt and os.time() > keyData.expiresAt then
return { success = false, error = "License expired" }
end
local personalizedSource = SCRIPT_SOURCE:gsub(
"PLAYER_ID",
tostring(player.UserId)
)
local ok, response = pcall(function()
return HttpService:RequestAsync({
Url = "https://www.cosmo-rblx.online/api/obfuscate",
Method = "POST",
Headers = {
["Authorization"] = "Bearer " .. API_KEY,
["Content-Type"] = "application/json",
},
Body = HttpService:JSONEncode({
source = personalizedSource,
mode = "vm",
}),
})
end)
if ok and response.Success then
local data = HttpService:JSONDecode(response.Body)
return { success = true, script = data.obfuscated }
end
return { success = false, error = "Obfuscation service unavailable" }
end
CI/CD Pipeline
Automate obfuscation as part of your build process. Protect all your scripts before deployment without manual intervention.
Rate limits are applied per account based on your active plan. Limits reset at midnight UTC each day. Bonus obfuscations carry over and are consumed after your daily limit is reached.
Plan
Daily Limit
Rate
Bonus Eligible
Free
10 / day
5 req/min
No
Basic
100 / day
15 req/min
Yes
Pro
500 / day
30 req/min
Yes
Enterprise
Unlimited
60 req/min
Yes
How Limits Work
Your daily counter resets at midnight UTC. Each successful obfuscation request counts as one unit regardless of input size. Failed requests (4xx or 5xx responses) do not count against your limit.
Bonus Obfuscations
Bonus obfuscations are extra credits earned through referrals, promotions, or plan upgrades. They persist across billing cycles and are consumed only after your daily limit is exhausted. Check your bonus balance via the /api/usage endpoint.
Response Headers
Every API response includes headers to help you track your usage programmatically:
{
"success": false,
"error": "A description of what went wrong",
"code": 400
}
Usage Object
The usage object is included in every successful obfuscation response so you can track consumption in real time.
Parameter
Type
Required
Description
current
number
Yes
Number of obfuscations used today
limit
number
Yes
Maximum daily obfuscations for your plan
bonus
number
Yes
Remaining bonus obfuscation credits
When current reaches limit, bonus credits are consumed automatically. The bonus field decrements accordingly. Once both are exhausted, subsequent requests return a 429 status.