Skip to content
BasiX Media

Getting started

The basix resource, exports and your first call.

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>. Your publicId is 8 characters, returned by GET /api/v1/me.
  • Uploads: multipart POST https://upload.basix.media/api/v1/upload with a file field and an optional path field.
  • Errors: { "error": { "code": "...", "message": "..." } } with a matching HTTP status on /api/v1 endpoints. 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/v1 endpoints, but uploads above 100 MB fail there and the compatible endpoints are not served there. Use upload.basix.media for everything.

Getting started

  1. 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.
  2. Download the resource from Dashboard → SDK and unzip it into resources/basix:
server.cfg
set basix_key "bx_live_yourkeyhere"
ensure basix
  1. 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
}
  1. Upload a file. Plain PerformHttpRequest cannot build a multipart body, which is exactly why the resource's exports.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]"
  1. Use the url from the response anywhere: NUI, loading screen, Discord, a website.

Connect my FiveM server to the CDN

  1. 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
  1. Get your publicId from GET /api/v1/me. Your images are now at https://cdn.basix.media/<publicId>/items/<name>.png.
  2. Point your inventory at that folder. For ox_inventory, in server.cfg:
text
setr inventory:imagepath "https://cdn.basix.media/<publicId>/items"
  1. In NUI or HTML, use the URL directly. Add ?w=128 for 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.

Create a free account
Getting started — FiveM docs — BasiX