FiveM
Install the basix resource and call its Lua exports from your server scripts.
On this page
Quick facts
- API base URL:
https://upload.basix.media/api/v1. Every endpoint answers there. - Auth:
Authorization: Bearer bx_live_...on every request. - CDN addresses:
https://cdn.basix.media/<publicId>/<path>. YourpublicIdis 8 characters, returned byGET /api/v1/me. - Uploads: multipart
POST https://upload.basix.media/api/v1/uploadwith afilefield and an optionalpathfield. - Errors:
{ "error": { "code": "...", "message": "..." } }with a matching HTTP status on/api/v1endpoints. The compatible endpoints use their own shape (see below). - Sizes: strings in list, detail and stats responses (
"size": "15320"). Numbers in upload responses ("size": 15320). - Max file size: 2048 MB. Images, video and audio only. The type is detected from the bytes, never from the name.
https://basix.media/api/v1/...also answers the/api/v1endpoints, but uploads above 100 MB fail there and the compatible endpoints are not served there. Useupload.basix.mediafor everything.
Getting started
With the basix resource (recommended)
- Create an account at https://basix.media, then create an upload scope key in Dashboard → API (https://basix.media/dashboard/api). The key is shown once — put it straight into
server.cfg, never into a client script. - Download the resource from Dashboard → SDK and unzip it into
resources/basix:
server.cfg
set basix_key "bx_live_yourkeyhere"
ensure basix- Call it from any server script:
Lua
exports.basix:upload({ data = base64Data, name = 'clip.webm', folder = 'clips' }, function(err, file)
if err then return print('[basix] ' .. err) end
print(file.url)
end)
exports.basix:screenshot(source, { folder = 'reports' }, function(err, file)
if err then return print('[basix] ' .. err) end
print(file.url)
end)Tip
Full details: Install the basix resource, the Lua exports reference (also covers presign and the logging exports), and every convar and the full server.cfg block.
Without the resource (raw HTTP)
Nothing you run outside FXServer — a web backend, a build script, a bot — can call exports. Talk to the API directly instead. This is also what the resource does under the hood.
PerformHttpRequest('https://upload.basix.media/api/v1/me', function(status, body)
print(status, body)
end, 'GET', '', { ['Authorization'] = 'Bearer ' .. GetConvar('basix_key', '') })Response:
json
{
"organization": { "name": "My Server", "publicId": "a7k2m9x4" },
"key": { "scope": "upload" },
"quota": { "bytes": "10737418240", "canUpload": true, "reason": null },
"used": { "bytes": "52428800", "files": 42, "fileBytes": "50331648", "logBytes": "2097152", "databaseBytes": "0" },
"plan": null,
"subscription": null
}- Upload a file. Plain
PerformHttpRequestcannot build a multipart body, which is exactly why the resource'sexports.basix:upload(base64, no multipart needed) exists — from outside FXServer, multipart is simple:
curl
curl -X POST https://upload.basix.media/api/v1/upload \
-H "Authorization: Bearer $BASIX_KEY" \
-F "path=items/burger.png" \
-F "[email protected]"- Use the
urlfrom the response anywhere: NUI, loading screen, Discord, a website.
Connect my FiveM server to the CDN
- Create an upload key. Upload your item images into one folder:
bash
for f in ./images/*.png; do
curl -s -X POST https://upload.basix.media/api/v1/upload \
-H "Authorization: Bearer $BASIX_KEY" \
-F "path=items/" -F "file=@$f" > /dev/null && echo "ok $f"
done- Get your
publicIdfromGET /api/v1/me. Your images are now athttps://cdn.basix.media/<publicId>/items/<name>.png. - Point your inventory at that folder. For ox_inventory, in
server.cfg:
text
setr inventory:imagepath "https://cdn.basix.media/<publicId>/items"
- In NUI or HTML, use the URL directly. Add
?w=128for small icons:
html
<img src="https://cdn.basix.media/<publicId>/items/burger.png?w=128" alt="">
<video autoplay muted loop src="https://cdn.basix.media/<publicId>/loading/intro.mp4"></video>Try it on your own server
Create a free account and your API key is ready in about two minutes. 3 GB included, bandwidth never billed, no card needed.